Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using JMS as a request/response service

There are various implementations for using JMS as a request/response service. I would like to know the ideal implementation. Below are these various implementations.


1) Permanent request queue, Dynamic response queue

All request messages are published into a single request queue specifying the reply queue. The service consumes the request message and publishes a message back onto a dynamic reply queue.

  • No need for a correlation id.
  • Multiple consumers of their corresponding response queues

2) Permanent request queue, Permanent response queue

All request message are published into a single request queue, specifying a unique id in the jms properties. Unique id is stored locally. Service consumes request message and publishes message back onto response queue. A single response consumer will consume the message and act appropriately based on the unique id.

  • Correlation id required.
  • Single consumer of the response queue

3) Permanent request queue, Permanent response topic

All request messages are published into a single request queue, specifying a unique id in the jms properties. The service consumes the request message and publishes a message with the same unique id in the jms properties back onto the topic. Consumers of the response will set a message selector to select for only the message the contains the unique id.

  • Correlation id required.
  • Multiple consumers of the response topic

Does anyone know other implementations? And which of these implementations is the ideal solution for using JMS as a request/response service?

like image 242
onejigtwojig Avatar asked Nov 04 '10 20:11

onejigtwojig


People also ask

Can JMS be used to send an email?

JMS (Java Message Service) is an API that provides the facility to create, send and read messages. It provides loosely coupled, reliable and asynchronous communication. JMS is also known as a messaging service. JMS is mainly used to send and receive message from one application to another.

Is JMS deprecated?

The classic API is not deprecated and will remain part of JMS indefinitely.

What services are provided by JMS?

JMS supports both messaging models: point-to-point (queuing) and publish-subscribe. JMS was defined to allow Java application to use enterprise messaging systems. More importantly, it provides a common way for Java applications to access such enterprise messaging systems.

What is difference between JMS and ActiveMQ?

What Is the Difference Between JMS and ActiveMQ? ActiveMQ is a JMS provider. A JMS provider forms the software framework for facilitating the use of JMS concepts inside an application. A single node of ActiveMQ which allows clients to connect to it and use these messaging concepts is called an “ActiveMQ Broker.”


1 Answers

This is what I usually do: Request posted to the 'permanent', 'well-known' queue. In the request message sender specifies replyTo queue which can be permanent or dynamic depending on your app. requirement.

Reasonably unique id/correlation id should always be used at least for traceability of the messages in the log files etc. It could be on JMS headers level or on payload level (e.g. SOAP messageId) depending on your requirements.

like image 132
maximdim Avatar answered Sep 22 '22 17:09

maximdim