Friday, December 14, 2012

Spring JMS ActiveMQ - Introduction/Perfomance

What is JMS?


Java Message Service(JMS) is a Specification/Interface/API provided by SUN for sending messages between two or more clients
JMS Producer (Client) ---> Provider/Broker/ActiveMQ ----> JMS Listener (Client)
Producer: In simple word it create message and send it to provider's destination Queue through JMSConnectionFactory
Destination: Destination is a .Queue where message resides in the provider.
Provider: Provide implements the JMS specification for sending messages between clients. ActiveMQ is one the well know provider. Provider is also known as broker as it does the job of transferring the message from producer to listener,
Listener: It listen to the queue when even there is a message in the queue listener process it inside onMessage method.
Persistence and Non-Persistence Mode: ActiveMQ in default runs in persistence mode. Persistence mode means message is persisted by the provider in file system or db. 
Why JMS Persistance Mode? 
Consider message is transferred from producer to provider, in persistence mode provider(ActiveMQ) will persist the message in file system. Consider listener is busy in processing other task or listener server is down. Due to some other issue if provider(ActiveMQ) server is also down if message is not persisted then message will be lost without reaching the listener. In our case since we run it in persistence mode message is persisted and it will be used by the listener when both provider and listener servers are up and running!  

JMS Performace:
Non-persistent delivery of message improves the performace of the overall system. 

When to use Non-Persistance mode:
For usage scenarios where only reliability is required we can go with non-persistance JMS, where as when we need guaranteed message delivery we can use persistance mode. Even in non-persistence mode JMS specification allows the messaging provider to make best efforts to deliver the message to currently active message consumers.

No comments:

Post a Comment