Java Messaging Service(JMS)
Overview
A system that supports messaging between computers in a network.
It provides a interface to standard messaging protocols and also to special messaging services in support of Java programs.
Reliable way for programs to create, send, receive and read messages in any distributed System.
Rather than communicating directly, components in an application based around a message service send messages to message server.
This server delivers message to the recipients.
Message-oriented middleware
It is fast, reliable electronic communication, guaranteed message delivery, receipt notification and transaction control and connects independent systems.
It also facilitated distributed processing – the connection of multiple applications together to create a larger application, usually over a network.
Relies on asynchronous message passing.
Disadvantages with MOM
Required an extra component in architecture, message transfer agent.
Reduced performance, reliability and more expensive.
Messaging System
This architecture replaces the client/server model with a peer-to-peer relationship between individual components, where each peer can send and receive messages to and from other peers.
It encourage "loose coupling" between message consumers and message producers.
It permits dynamic, reliable, and flexible systems to be built, where sub-applications can be modified without affecting the rest of the system.
Tightly coupled architecture
JMS API JMS API enable communication that is:-
Asynchronous. JMS provider deliver messages to a client as they arrive; client does not have to request messages in order to receive them.
Reliable. JMS API ensure that a message is delivered only once. Lower levels of reliability are available for applications to receive duplicate messages.
Specific goals of the JMS API :
Provide an API suitable for the creation of messages that match the format used by existing, non-JMS applications .
Support the development of heterogeneous applications that span operating systems, platforms, architectures, and computer languages
Support messages that contain XML pages.
JMS Architecture
A JMS provider is a messaging system that implements the JMS interfaces and provides administrative and control features.
JMS clients are the programs or components, written in the Java programming language, that produce and consume messages.
Messages are the objects that communicate information between JMS clients.
Administered objects are preconfigured JMS objects created by an administrator for the use of clients.
Native clients are programs that use a messaging product's native client API instead of the JMS API.
Steps for developing a client applications are:
Resolve a connection factory and a destination from JNDI. A destination is either a queue or a topic.
Create a connection using the connection factory.
Create a session with the desired properties from the connection.
If the application is a supplier, create a MessageProducer; if the application is a consumer, create a MessageConsumer from the session.
Start to send or receive messages using the producer or consumer object. A producer will use the session to create different kinds of messages.
Messaging system models
The most common messaging models are:
Publish-Subscribe Messaging
Point-To-Point Messaging
Request-Reply Messaging
Publish-Subscribe Messaging
Steps in this model:
Subscriber registers instance of class that implements MessageListener by invoking s.setMessageListener(l), s is subscriber and I is listener to topic.
Publisher creates and publish message by invoking p.publish(m), m is message .
At last topic delivers the message to subscriber by l.onmessage(m).
Point-To-Point Messaging
Many-to-one paradigm, where many clients can send messages to a single client.
Multiple Senders of messages, only a single Receiver for the messages.
Steps in this model:
QueueSender s, sends message m
to the queue.
QueueReciever r is ready to receive
the message from queue.
Queue sends message to QueueReciever.
Request-Reply Messaging
An application sends a message and expects a reply to that message from the receiver.
This is the standard synchronous object-messaging format.
Used for both synchronous and asynchronous service requests.
This can be done using “reply to” field in the message or by creating a new ‘acknowledge-queue’ to which clients response.
Asynchronous
Advantages of JMS
It let programmers built software independent of messaging mechanisms. This enhances the reusability of the components and minimizes development time for the application.
It is responsible for reliable delivery. This frees the components of the application from having to deal with these fairly generic issues.
It is responsible for delivering and queuing the messages to the clients. This free up the servers to process more information.
JMS Limitations
Doesn’t support load balancing mechanisms. Most products support multiple ,cooperating clients implementing a critical service. It won’t let different clients to act together to perform as a single client.
JMS does not specify how to implement digital signatures to verify the authenticity.
JMS API does not define an API to administer the message products.

No comments:
Post a Comment