Java Message Service

September 21st, 2006 by uCertify Leave a reply »

JMS, which stands for Java Message Service, is also referred to as Messaging Oriented Middleware (MOM). It defines standards for reliable enterprise messaging. As JDBC provides access to many different relational databases, in the same way, JMS provides vendor-neutral access to enterprise messaging systems.

JMS clients are Java applications that make use of JMS, and the JMS provider is the name given to the messaging system that handles the sending and receiving of messages. The JMS client that sends a message is known as a producer, and the JMS client that receives the message is known as a consumer. JMS provides asynchronous messaging, i.e., a JMS client can send messages without waiting for its reply.

The following are JMS elements:

  1. JMS provider: An implementation of the JMS interface for a Message Oriented Middleware (MOM). Providers are implemented as either a Java JMS implementation or an adapter to a non-Java MOM.
  2. JMS client: An application or process that produces and/or receives messages.
  3. JMS producer: A JMS client that creates and sends messages.
  4. JMS consumer: A JMS client that receives messages.
  5. JMS message: An object that contains the data being transferred between JMS clients.
  6. JMS queue: A staging area that contains messages that have been sent and are waiting to be read. As the name queue suggests, the messages are delivered in the order sent. A message is removed from the queue once it has been read.
  7. JMS topic: A distribution mechanism for publishing messages that are delivered to multiple subscribers.

The JMS API supports two models:

  1. Point-to-point or queuing model
  2. Publish and subscribe model

Point-to-point or queuing model: In the point-to-point or queuing model, a producer posts messages to a particular queue and a consumer reads messages from the queue. Here, the producer knows the destination of the message and posts the message directly to the consumer’s queue. It is characterized by the following:

  • Only one consumer will get the message.
  • The producer does not have to be running at the time the consumer consumes the message, nor does the consumer need to be running at the time the message is sent.
  • Every message successfully processed is acknowledged by the consumer.

Publish and subscribe model: The publish/subscribe model supports publishing messages to a particular message topic. Subscribers may register interest in receiving messages on a particular message topic. In this model, neither the publisher nor the subscriber knows about each other. A good metaphor for it is anonymous bulletin board. The following are the characteristics of this model:

  • Multiple consumers can get the message.
  • There is a timing dependency between publishers and subscribers. The publisher has to create a subscription in order for clients to be able to subscribe. The subscriber has to remain continuously active to receive messages, unless it has established a durable subscription. In that case, messages published while the subscriber is not connected will be redistributed whenever it reconnects.

Using Java, JMS provides a way of separating the application from the transport layer of providing data. The same Java classes can be used to communicate with different JMS providers by using the JNDI information for the desired provider. The classes first use a connection factory to connect to the queue or topic, and then use, populate, and send or publish the messages. On the receiving side, the clients then receive or subscribe to the messages.

The following are the uses of JMS:

  1. Enterprise Application Integration: It is used where a legacy application is integrated with a new application via messaging.
  2. B2B or Business to Business: Businesses can interact with each other via messaging because JMS allows organizations to cooperate without tightly coupling their business systems.
  3. Geographically dispersed units: JMS can ensure safe exchange of data amongst the geographically dispersed units of an organization.
  4. One-to-many applications: The applications that need to push data in a packet to a huge number of clients in a one-to-many fashion are good candidates for the use of JMS. Typical such applications are Auction Sites, Stock Quote Services, etc.

Difference with RPC:

In RPC, the method invoker waits for the method to finish execution and return the control back to the invoker. Thus, it is completely synchronous in nature. In JMS, the message sender just sends the message to the destination and continues its own processing. The sender does not wait for the receiver to respond. This is asynchronous behavior.

Copyright © 2009-2010 Wikipedia. All rights reserved.

Pass SCJA in first attampt. Download free practice test for SUN SCJA exam.
Like this article? Share it with others
If you like this article, please leave a comment or subscribe this blog via RSS or via e-mail, Bookmark and share through your network. Click the AddThis button below. Thanks.
  • Share/Bookmark
Advertisement

Leave a Reply

uCertify.com | Our Company | Articles | Contact Us | News and Press Release | uCertify India | Entries (RSS)
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD    Cisco Certification: CCNA, CCENT    A+, Network+, Security+ Project+
Oracle Certification: OCP 11g, OCP 10g, OCA 11g, OCA 10g    CIW foundation    EC-212-32,    CISSP    Photoshop ACE CS4    Adobe Flash ACE, PMP, CAPM
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.