Saturday 20 February 2016

An overview of the Message Oriented Middleware with JMS

Message oriented middle-ware allows software components that have been developed independently on different networking platforms to interact with one another. Applications in a distributed system across network node use the API to communicate without the worrying about the underlying details of the operating system. The API sits above the middle-ware layer in a distributed system. The Message Oriented Middle-ware (MOM) allows distributed applications to communicate and exchange data by sending and receiving messages.

Message queues are also referred to as Message-Oriented Middle-ware. This is a class of commercial middle-ware with key implementations including IBM's WebSphere MQ and Oracle's Stream Advanced Queuing. Main aim off these products is to achieve Enterprise Application Integration, this is achieved by loose coupling and message queues. These systems are used in commercial transaction processing systems.

In the programming model for these queues. we take an approach where we send messages to a queue and other processes. The following generally support the following;

  • A blocking receive, this blocks until the appropriate message is received.
  • A non-blocking receive, will check the status of the queue and return a message if one is available.
  • A notify operation, causes an event to issue a notification that corresponds to the associated queue.

The queuing policy is first-in-first-out (FIFO), other queue implementations also support the concept of priority, with higher-priority messages being delivered first.

The Java Messaging Service is a standardized method for a distributed Java program to communicate indirectly.

A JMS broker provides clients with connectivity, it stores messages and deliver functions. A message in JMS is an object that contains the required heading fields, optional properties and data payload being transferred between JMS clients. The destinations are maintained by the message broker. This can be either queues or topics.

A queue offers point to point model, only one consumer gets the message and messages have to be
sent in specific order as in earlier part of where queue messages can’t be delivered out of order. A
queue only guarantees that each message is processed only once. Like in the lab when the producer
submits a message to the queue and we can browse the queue and decide which messages we want
to receive and which we want to purge or delete.

A topic offers publish and subscribe model where multiple clients can subscribe to a message. In
topics there is no guarantee that each message is processed only once and the subscriber needs to
be active when message is produced unless subscription was durable.

The JMS client is essentially a Java program that produces and consumes messages, a JMS producer is a program that creates and produces messages and a JMS consumer is program that receives and consumes messages.
  • A JMS provider is any system that implements the JMS specification.
  • A JMS message is simply an object that is used to communicate information between JMS clients.
  • A JMS destination is an object supporting indirect communication in JMS. This is either a topic or queue.
The first step that is required to interact with the JMS provider is to initiate a connection between a client and provider program. This connection is channel between the client and provider in form of a TCP/IP socket.

Twp types of connections can be established a Topic Connection or a Queue Connection.

Connections can be used to create sessions, a session is a series of operations involving the creation, production and consumption of messages related to a task.

A Topic Connection can support one or more topic connections and a Queue Connection can support one or more queue connections. However we cannot combine different type of sessions together in a connection.

The session is the central component to the operation of JMS. A session consists of a series of operations involving the creation, production and consumption of messages related to a task.

A message consists of thee parts, a header, a set of properties and a body of the message.

Code examples can be found in the link below:
https://github.com/JunSoftware109/Java_Exercises/tree/master/Lab%204%20MOM/exploring-jms

For detailed information check out : http://docs.oracle.com/javaee/6/tutorial/doc/bnceh.html