Java Message Service (JMS)

Java Messaging is a mechanism that lets programs to communicate with one another using Middle Oriented Middleware (MOM). The application can creating, sending, receiving, and reading message. The Java Messaging Service (JMS) is a standard API for accessing message-oriented middleware

Messaging technologies include these:

  • TCP/IP Sockets
  • Pipes
  • Files
  • Shared Memory

Why Message Oriented Middleware (MOM)?
Messaging enables de-coupled communication. Sometimes it is called loosely-coupled communication. It is de-coupled communication because the sender does not have to know the details of the receiver. For example, the sender does not have to know whether a receiver is a live process or not or the location information of it such as IP address or port number. Instead the sender and receiver of messages communicate via an intermediary communication framework called messaging system or MOM.
  • Single point of integration
  • Loosely-coupled integration
  • Simplified Integration of different platforms and applications
  • Asynchronous communication
  • Reliable communication
Message Structure
JMS Messages have three parts:
  • Message Header :fixed set of fields defined by JMS
  • Message Properties : used for message filtering and selection optional fields defined by JMS specification, Application and JMS Provider (vendor)
  • Message Body :used to transport application specific information

JMS API Programming Model : A JMS application is composed of the following parts :
  • JMS Provider : It is a messaging system that implements the JMS interfaces and provides administrative and control features.
  • JMS clients : are the programs or components, written in Java that produce and consume messages.
  • Messages : are the objects that communicate information between JMS clients.
  • Administered objects : are JMS objects created by an administrator on server. Both sender and receiver connects to this administrator objects for communicating each other. The two kind of administrator objects are created - Connection Factory and desctination ( Queue/Topic) .
The basic building blocks of a JMS application are:
  • JMS Connections A connection encapsulates a virtual connection with a JMS provider. A connection could represent an open TCP/IP socket between a client and a provider service daemon.
  • JMS Sessions
    • A session is a single-threaded context for producing and consuming messages.
    • It is used to create Message producers, message consumers, messages, queue browsers.
    • Sessions serialize the execution of message listeners.
    • A session provides a transactional context with which to group a set of sends and receives into an atomic unit of work.
  • JMS message producer: A message producer is an object that is created by a session and used for sending messages to a destination
  • JMS message consumer: A message consumer is an object that is created by a session and used for receiving messages sent to a destination
  • JMS messages: JMS messages have a basic format that is simple but highly flexible, allowing you to create messages that match formats used by non-JMS applications on heterogeneous platforms
  • Administered objects:
    • A connection factory is the object a client uses to create a connection to a provider.
    • It encapsulates a set of connection configuration parameters that has been defined by an administrator.
    • A destination is the object a client uses to specify the target of messages it produces and the source of messages it consumes.
    • In the PTP messaging domain, destinations are called queues. In the pub/sub messaging domain, called topics. A JMS application can use multiple queues or topics (or both).
Messaging Models :
  • Point to Point :
    • A message is consumed by a single consumer
    • A message is consumed by a single consumer
    • There could be multiple senders
    • Messages are passed via Queues (Destination of a message)
    • Senders send message to a named queue
    • Receiver extract message from the queue
    • First in First out (at the same priority level)
  • Publish/Subscribe :
    • A message is consumed by multiple consumers
    • Message consumed by Zero or more consumers
    • Messages are passed via Topics (Destination of Message)
    • Publisher publish to topic
    • Subscriber subscribe to topic
Previous   Next

Comment by : Daniele October 3rd, 2015
Comment : Thanks for every other informative blog. Where else could I get that kind of info wiettrn in such an ideal approach? I have a challenge that I am simply now working on, and I have been on the look out

Share your valuable comment

Name :
Email Id : [ We will not publish your email id ]
Your Comment : [ Maximum 200 chars ]
Enter Security code :