Berlin Brown
Berlin Brown

Reputation: 11734

From a Webapp and with Apache Camel / and using MQ, do you add JMS messages using jsessionid?

I have a web application that will launch a message (say start processing) on the MQ message queue. I have a consumer and the producer configuration defined using the Camel Spring DSL. I want to push a message from a web application and only that session and client should get the response. Could I use the jsessionid and maybe some other random message id to set the message so only that client will get the response?

E.g. Imagine Camel Spring DSL xml configuration:

  <route id="webRequestToInRoute">
      <to uri="activemq:queue:inbox :::: here I want to getJsessionId() as the message ... name?"/>
  </route>

More importantly, what are ways that I can communicate between the browser to the camel rest service to the JMS route, mainly to pull the status?

Upvotes: 4

Views: 157

Answers (1)

Matt Pavlovich
Matt Pavlovich

Reputation: 4306

Web app session publishes message

  1. set JMSReplyTo header on the message to: temp-queue://ORDER.$jSessionId
  2. setup a consumer on temp-queue://ORDER.$jSessionId
  3. send to -> queue://PROCESS.ORDER

On the REST service

  1. Consume from queue://PROCESS.ORDER
  2. Do stuff with message
  3. Publish response to temp-queue://ORDER.$jSessionId

Once there are no longer messages, consumers or producers the broker will automatically delete the temp-queue, so there is no clean-up necassary

Upvotes: 1

Related Questions