Understanding Basic Components of a JMS Program

JMS stands for Java Message Service which can be considered as a postal service which enables java applications and their components to communicate. JMS is a standardized messaging agent which provides a way to send and receive messages to J2EE components. We can divide JMS into five components each of which corresponds to a specific JMS programming component too.

First is provider which has the responsibility of managing the message service. The programming component corresponding to provider is administered objects. Two examples of administered objects are connection factory object and session object. These two are also related to each other. Connection factory is used to build the session object and session object creates sender or receivers which are further used for sending and receiving messages between applications.


_______________________________________________

Second fundamental component of JMS is client. Clients are the actual users of messaging services. Client can be a web application or a J2EE component and they use providers for accessing messaging services.

Next we have messages which are the objects or piece of information transmitted between clients. Message consists of a header which is the required part. The other two parts of message are properties and body which are optional.

Header has the fields which are necessary for the transmission of message. Message property contains some additional fields which are used to filter messages. Message body contains the actual message. There can be different message formats like TextMessage, BytesMessage, ObjectMessage or StreamMessage.

The next two components of JMS are Message Producers and Message Consumers. Message producers are objects responsible for creating the messages. A producer can create messages of different formats and can send them to different destinations. Methods used by message producer to transmit the message are send() or publish().

As the name indicates, Message Consumers are present at the destination and receive the messages sent by producers. For receiving the messages of their interest, consumers need to register themselves with the JMS provider.

Message producers, Message Consumers and messages are created by session object. Session can be explained as a context which creates above mentioned objects. As we know session object is created using the Connection object. Consider the following code snippet which describes the creation of a session object referred as sess1:

Session sess1 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

Here we have to arguments. First is false which implies that session created here is not transacted. Second is AUTO_ACKNOWLEDGE which means that after the receipt of messages, session automatically acknowledge them. Session can also be transacted if use the following code:

Session sess1 = connection.createSession(true, 0);

Here true indicates the transacted session and 0 implies that there is no auto acknowledgement after the receipt of message by the session.



_______________________________________________

FREE Subscription

Subscribe to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.

Name:
Email:

Note : We never rent, trade, or sell my email lists to
anyone. We assure that your privacy is respected
and protected.

_______________________________________



| All About Different Types of XML Editors | Generating XML Document Using JSP | How to Retrieve an Email Message Using Java Mail API | How to Send an Email Message Using Java Mail API | Transforming XML Data with XSLT | Understanding Basic Components of a JMS Program | Understanding Basic Technology of ebXML | Understanding Deployment Descriptor in Reference with Servlets | Understanding eXtensible Access Control Markup Language (XACML) | Understanding the Design Goals of XML | Understanding XML Common Biometric Format |

FREE Subscription

Stay Current With the Latest Technology Developments Realted to XML. Signup for Our Newsletter and Receive New Articles Through Email.

Name:

Email:

Note : We never rent, trade, or sell our email lists to anyone. We assure that your privacy is respected and protected.

 

 

Add to My Yahoo!

Visit XML Training Material Guide Homepage

 

 

 

Copyright - © 2004 - 2017 - All Rights Reserved.