JMS
MOM (Message Oriented Middleware)
MOM is a software/hardware infrastructure supporting sending/receiving messages between distributed applications.
JMS (Java Message Service)
- JMS is no way related with Java Mail.
- JMS supports Asynchronous communication.
- JMS API is a Java Message Oriented Middleware API for sending messages between two or more clients.
- JMS is a part of the Java Platform, Enterprise Edition, and is defined by a specification developed under Java Community Process.
- It is a messaging standard that allows application components to create, send, receive and read messages.
- Messaging means "loosely-coupled distributed communication", where communication is between two software components.
JMS elements:
- JMS Provider: An implementation of the JMS interface for a Message Oriented Middleware. JMS server/ provider supplies, destinations having capability to store messages temporarily.
- MQ series from IBM
- MSMQ from Microsoft
- Weblogic Message Server from Weblogic(Application server)
- Glassfish Message Server from Glassfish(Application server)
- Every Application server supplies one built-in JMS server.
- JMS Client:
- A application or process that produces and/ or receives messages.
- JMS Producer/ Publisher:
- A JMS Client that creates and sends messages.
- JMS Consumer/ Subscriber:
- A JMS Client that receives messages.
- JMS Message:
- An Object that contains data being transferred between JMS clients.
- JMS Queue:
- A staging area that contains messages that have been sent and are waiting to be read. Note that, contrary to what the name queue suggests, messages don't have to be delivered in the order sent. The JMS Queue only guarantees that each processed only once.
- JMS Topic:
- The distributed mechanism for publishing messages that are delivered to multiple subscribers.
A JMS Application is composed of the following parts:
- JMS provider is a messaging system that implements the JMS interfaces and provides administrative and control freatures.
- JMS clients are the programs or components, written in Java programming language, that produce and consume messages.
- Messages are the objects that communicate information between JMS clients.
- Administrated objects are preconfigured JMS objects created by Administrator for use of clients. The two types of administrated objects are destinations and connection factories.
- Native clients programs that use a messaging product's native API instead of JMS API.
Fig: JMS Architecture
CF- Connection factory, D - destination
CF- Connection factory, D - destination
Messaging Domain:
- There are two approaches of Messaging
- Point-to-Point Messaging Domain:
- Fig: PtoP overview
- uses JMS Queue
- Each message has only one consumer.
- The receiver acknowledges the successful processing of a message.
- Publish/ Subscribe Messaging Domain:
- Fig: Pub-Sub overview
- uses JMS Topic
- Each message can have multiple consumers.
- Connections
- Sessions
- Message producers
- Message consumers
- Message selectors
- Message listeners
- Messages
- A JMS Message has three parts
- Header
- Properties(optional)
- Body(optional)
Import resources of JMS API related to Queue:
- QueueConnectionFactory (I)
- QueueConnection (I)
- Queue (I)
- QueueSession (I)
- QueueSender (I)
- QueueReceiver (I) and etc....
- TopicConnectionFactory (I)
- TopicConnection (I)
- Topic (I)
- TopicSession (I)
- TopicPublisher (I)
- TopicSubscriber (I) and etc...
Create Queue and Topic Destinations:
- Create JMS Connection factory having a JNDI name:
- JMS Connection facotry represents JMS Connection pool.
- Each Connection object represents the connection between Client Application and JMS Server.
- Create Queue destination having a JNDI name
- Create Topic destination having a JNDI name
References:
No comments:
Post a Comment