Java Messenging Service(JMS) – Part-1

JMS is a way of communication between message producers and message consumers.

How is it different from RMI?

Remote Method Invocation(RMI) is tightly coupled in the sense it requires an application to know a remote application’s methods to invoke.

Where as JMS is loosely coupled in the sense that the sender does not need to know anything about the receiver; nor does the receiver need to know anything about the sender.The sender and the receiver need to know only what message format and what destination to use.The producers send messages to some destination and consumers read messages from that destination.

How is it different from E-mail Service ?

E-mail is a method of communication between people or between software applications and people, where as JMS is a method os communication between software applications or software components.

Messenging Domains:

  • Point to Point Messenging :
    Each message is meant for only one consumer and
    it acknowledges the successful processing of a message.
  • Publish-Subscribe Messenging:

Each message may have multiple subscribers and each subscriber subscribes to a particular Topic for consumption and they  must continue to be active in order for it to consume messages

What is MOM and How it is related to JMS:

A JMS application is composed of the following parts:

  • A JMS provider: A messaging system that implements the JMS specification.
  • JMS clients: Java applications that send and receive messages.
  • Messages: Objects that are used to communicate information between JMS clients.
  • Administered objects: Preconfigured JMS objects that are created by an administrator for the use of JMS clients.Aadministrators configure administered objects in a JavaTM Naming and Directory InterfaceTM (JNDI) API namespace, and JMS clients then look them up, using the JNDI API. J2EETM applications always use the JNDI API.

A message is composed of three parts: header, properties, and a body.

  • The header, which is required for every message, contains information that is used for routing and identifying messages. Some of these fields are set automatically, by the JMS provider, during producing and delivering a message, and others are set by the client on a message by message basis.
  • Properties, which are optional, provide values that clients can use to filter messages. They provide additional information about the data, such as which process created it, the time it was created. Properties can be considered as an extension to the header, and consist of property name/value pairs. Using properties, clients can fine-tune their selection of messages by specifying certain values that act as selection criteria.
  • The body, which is also optional, contains the actual data to be exchanged. The JMS specification defined six type or classes of messages that a JMS provider must support:
    1. Message: This represents a message without a message body.
    2. StreamMessage: A message whose body contains a stream of Java primitive types. It is written and read sequentially.
    3. MapMessage: A message whose body contains a set of name/value pairs. The order of entries is not defined.
    4. TextMessage: A message whose body contains a Java string…such as an XML message.
    5. ObjectMessage: A message whose body contains a serialized Java object.
    6. BytesMessage: A message whose body contains a stream of uninterpreted bytes.

The JMS flow looks like this:

Here in the above pic. both Destionations are the same .The above pic has been taken from  here

Advertisement
Posted in JMS. Tags: , . Leave a Comment »

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.