Java Messaging Service
•Java Message Service (JMS) is a standard API for accessing message-oriented middleware.
• JMS is beneficial because it allows:
– two Java programs to communicate even if one of them is unavailable
– queuing of messages for faster performance
• JMS is beneficial because it allows:
– two Java programs to communicate even if one of them is unavailable
– queuing of messages for faster performance
•Application A wishes to send messages to Application B
•A is the “Producer” - “Sender” – “Publisher”
•B is the “Consumer” – “Receiver” – “Subscriber”
•A is the “Producer” - “Sender” – “Publisher”
•B is the “Consumer” – “Receiver” – “Subscriber”
JMS Basics
•Messaging models:
•Point to point (Queue)
•Publish/subscribe (Topic)
•
•JMS Administered objects
•Connection Factory
•Connection
•Session
•Destination
•Producer/Publisher
•Receiver/Subscriber
Point-to-Point (PTP) Messaging Domain
•Each message has only one consumer
•The receiver acknowledges the successful processing of a message
•A sender and a receiver of a message have no timing dependencies: the receiver can fetch the message whether or not it was running when the sender send the message.
•Messaging models:
•Point to point (Queue)
•Publish/subscribe (Topic)
•
•JMS Administered objects
•Connection Factory
•Connection
•Session
•Destination
•Producer/Publisher
•Receiver/Subscriber
Point-to-Point (PTP) Messaging Domain
•Each message has only one consumer
•The receiver acknowledges the successful processing of a message
•A sender and a receiver of a message have no timing dependencies: the receiver can fetch the message whether or not it was running when the sender send the message.
Publish/Subscribe (Pub/Sub) Messaging Domain
•Each message may have multiple consumers
•Publishers and subscribers have a timing dependency unless durable subscription is used.
•Each message may have multiple consumers
•Publishers and subscribers have a timing dependency unless durable subscription is used.
Queue
1) In queues, one message can be consumed
by only one client.
2) Queue represent Point-To-Point model.
3) queue is used to send one to one system.
4) In queue the messages are send
to FIFO(First in first out) order.
Topic
1) In the topics, one message can be consumed
by many clients.
2) Topic represent Public and Subscribe model.
3) topic is used to send more than one system
at a time.
4) In Topic the messages are send to LIFO
(Last in first out) order.
ConnectionFactory
Encapsulates connection configuration information, and enables JMS applications to create a Connection.
Supports concurrent use, enabling multiple threads to access the object simultaneously
WebLogic automatically provides two connection factories:
–weblogic.jms.ConnectionFactory—a non-XA capable factory.
–weblogic.jms.XAConnectionFactory—an XA-capable factory
Transaction parameters – Transaction timeout
Security configuration
Flow control
Define if you want JMS server to Load-balance and enable server-affinity
Server affinity must be turned off and load balance should be enabled to see perfect load balancing
Note: If load is unevenly distributed despite the above settings, check for cluster problems.
Connection
•Definition Represents an open communication channel to the messaging system. A connection is used to create sessions.
•Created by ConnectionFactory
•ConnectionFactory.createConnection()
•Creates Sessions
•Connection.createSession()
•Due to the authentication and communication setup done when a Connection is created, a Connection is a relatively heavyweight JMS object.
•Stopped by default. Must be started to receive messages
Session
•Definition: serial order for the messages produced and consumed
•Creates producers, consumers, and messages.
•The same thread can be used for producing and consuming messages
•Adds value to Connection:
•Defines order of messages consumed and messages produced (done serially)
•Guarantees delivery by storing message until ACK by consumer queue
Persistence
•A persistent message is guaranteed to be delivered at least once—it is not considered sent until it has been safely written in the file or database. WebLogic JMS writes persistent messages to a persistent backing store (file or JDBC database) assigned to each JMS server during configuration.
•
•Non-persistent messages are not stored. They are guaranteed to be delivered at least once unless there is a system failure, in which case messages may be lost. If a connection is closed or recovered, all non-persistent messages that have not yet been acknowledged will be redelivered. Once a non-persistent message is acknowledged, it will not be redelivered.
JMS Labs
In Order to configure JMS in weblogic server we have to create 4 resources
1.JMS server
2.JMS module
3.Sub Deployment
4.Resources -Queues and Topics
1) In queues, one message can be consumed
by only one client.
2) Queue represent Point-To-Point model.
3) queue is used to send one to one system.
4) In queue the messages are send
to FIFO(First in first out) order.
Topic
1) In the topics, one message can be consumed
by many clients.
2) Topic represent Public and Subscribe model.
3) topic is used to send more than one system
at a time.
4) In Topic the messages are send to LIFO
(Last in first out) order.
ConnectionFactory
Encapsulates connection configuration information, and enables JMS applications to create a Connection.
Supports concurrent use, enabling multiple threads to access the object simultaneously
WebLogic automatically provides two connection factories:
–weblogic.jms.ConnectionFactory—a non-XA capable factory.
–weblogic.jms.XAConnectionFactory—an XA-capable factory
Transaction parameters – Transaction timeout
Security configuration
Flow control
Define if you want JMS server to Load-balance and enable server-affinity
Server affinity must be turned off and load balance should be enabled to see perfect load balancing
Note: If load is unevenly distributed despite the above settings, check for cluster problems.
Connection
•Definition Represents an open communication channel to the messaging system. A connection is used to create sessions.
•Created by ConnectionFactory
•ConnectionFactory.createConnection()
•Creates Sessions
•Connection.createSession()
•Due to the authentication and communication setup done when a Connection is created, a Connection is a relatively heavyweight JMS object.
•Stopped by default. Must be started to receive messages
Session
•Definition: serial order for the messages produced and consumed
•Creates producers, consumers, and messages.
•The same thread can be used for producing and consuming messages
•Adds value to Connection:
•Defines order of messages consumed and messages produced (done serially)
•Guarantees delivery by storing message until ACK by consumer queue
Persistence
•A persistent message is guaranteed to be delivered at least once—it is not considered sent until it has been safely written in the file or database. WebLogic JMS writes persistent messages to a persistent backing store (file or JDBC database) assigned to each JMS server during configuration.
•
•Non-persistent messages are not stored. They are guaranteed to be delivered at least once unless there is a system failure, in which case messages may be lost. If a connection is closed or recovered, all non-persistent messages that have not yet been acknowledged will be redelivered. Once a non-persistent message is acknowledged, it will not be redelivered.
JMS Labs
In Order to configure JMS in weblogic server we have to create 4 resources
1.JMS server
2.JMS module
3.Sub Deployment
4.Resources -Queues and Topics
Click on the Messaging ===>JMS servers.
A new page will load and now click on lock and Edit and then click on new to create a new JMS Server
Give the name of the JMS server and if you want to have a persistent store then create it ,Or if you don't create it will pick the default persistence store of the Server where you have targeted the JMS server.
Now Press Next
Now Press Next
Target the JMS server on any of the server .In our case we are targeting the JMS server on AdminServer