JMS Administered Objects and JMS Message

Filed Under: JMS

Before reading this post, please go through my previous at “JMS Messaging Models” to understand some JMS Basic concepts.

In this post we are going to discuss about JMS Administered Objects and JMS Message in detail.

Post Brief TOC:

  • JMS Administered Objects
  • JMS Message
  • Message Header
  • Message Properties
  • Message Body

JMS Administered Objects

JMS API provides two kinds of Administered Objects to the JMS Clients.

  • Connection Factory
  • Destination

JMS System Administrator creates these two Administered objects in JMS Provider (Message Broker) by using Application Server (AS) admin console. These two objects are stored in AS JNDI Directory or JNDI Registry.

Destination
Destination object is used to exchange messages between JMS Clients. JMS API provides two kinds of Destinations:

  • Queue
  • Topic

Connection Factory
Connection Factory object is used to create connection between JMS Provider and JMS Client. When JMS Client (JMS Sender or JMS Receiver) lookups this object from JNDI Registry, then JMS Client receives one Connection object that is nothing but a physical connection between JMS Provider and JMS Client. By using this connection, JMS Client can communicate with Destination object to send or receive messages into Queue or Topic.

jms_admin_objects

While creating these two objects, we need to provide three things

  • Name :- Name of the object. We can provide any valid name
  • JNDI Name:- This is JNDI name which is used to register this object in JNDI Directory. JMS Clients uses this name to lookup these objects from JNDI Registry and use them in their applications to send or receive messages from JMS Provider.
  • Resource Type:- We need to specify the resource type here.
S.No. Administered Objects Resource Type
1. ConnectionFactory javax.jms.ConnectionFactory
2. Queue javax.jms.Queue
3. Topic javax.jms.Topic

Example:-

To create a Queue Object in Oracle GlassFish Application Server

queue_creation

Here I’ve provided Destination Name = TPQueue , JNDI Name = jms/TPQueue and Resource Type as javax.jms.Queue. JMS Clients can lookup this object by using the following code snippet:


Queue queue = (Queue) context.lookup("jms/TPQueue");

JMS Message

JMS Messages are used by JMS clients to exchange information between systems. This JMS Message is of type javax.jms.Message.

This JMS Message is divided into 3 parts:

  • Message Header
  • Message Properties
  • Message Body

jms_message

Message Header

This section is mandatory. It contains predefined name-value pairs used by JMS Clients and JMS Providers to identify and route messages.

Predefined Headers:

  • JMSDestination
  • JMSDeliveryMode
  • JMSMessageID
  • JMSTimestamp
  • JMSCorrelationID
  • JMSReplyTo
  • JMSRedelivered
  • JMSType
  • JMSExpiration
  • JMSPriority

Message Properties

This section is optional. These properties are custom name-value pairs set or read by applications. These are useful for supporting filtering messages. We will discuss it in detail in Messaging Filtering Advanced JMS Concepts section.

Message Body

This section is optional. It contains actual message sent from JMS Sender to JMS Receiver.

It supports the following message formats:

  • TextMessage
  • ObjectMessage
  • BytesMessage
  • StreamMessage
  • MapMessage

These JMS message types are described in the following table:

jms_message_types

That’s it all about JMS Administered Objects and JMS Message. We will discuss some more JMS Concepts in my coming posts.

Please drop me a comment if you like my post or have any issues/suggestions.

Leave a Reply

Your email address will not be published. Required fields are marked *

close
Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages