Shriram Sharma
Shriram Sharma

Reputation: 639

JMS design: topic and queue combination

I am relatively new to JMS and I have been reading a lot on it lately.

I am planning to design a web app which would do the following:

  1. User logs into the system and publishes a message/question to a topic.

  2. All the users who have subscribed to the topic read the message/question and reply to it.

  3. The originator reviews all the answers and picks the best answer.

  4. The originator now replies to only the user whose answer he/she picked and asks for further clarification.

  5. The responder gets the message and replies.

So, once the originator has picked the answer, the JMS now becomes a request/reply design.

My questions are:

  1. Is it possible to publish to a topic with setJmsReplyTo(tempQueue)?

  2. Can request/reply approach be async?

  3. Is it a good idea to have per user queue?

These questions might some dumb to some of the experts here, but please bare in mind that I am still learning.

Thanks.

Upvotes: 2

Views: 293

Answers (2)

Dmitry
Dmitry

Reputation: 332

  1. JMSReplyTo is just a message header, nothing else. So It is possible to publish a message withing a topic with specific value in this header.

  2. Sure! If you would like to create a scalable system you should design event driven system using async instead of blocking aproach. MessageListener can help you.

  3. It is specific to JMS broker implementation. If queue creation is quite cheap there is no problems with such a solution.

Upvotes: 0

araknoid
araknoid

Reputation: 3125

Is it possible to publish to a topic with setJmsReplyTo(tempQueue)?

You should be able but I'm not 100% sure about it. By the way, I searched in my bookmarks and found this link that should explain what you have to do to build up a Request/Response system using JMS

http://activemq.apache.org/how-should-i-implement-request-response-with-jms.html

Can request/reply approach be async?

A message listener is an object that acts as an asynchronous event handler for messages. So you approach about request/reply, if using JMS, is by default async.

http://docs.oracle.com/javaee/1.3/jms/tutorial/1_3_1-fcs/doc/prog_model.html#1023398

Is it a good idea to have per user queue?

I don't know how many user you expect to have but having one queue for each user is not a good way to handle the messages. I had a problem similar to yours but we used a single queue for each of the macro area and we structured the message to hold the information of the user that sent it in order to store the information later and use it to further analysis.

Upvotes: 1

Related Questions