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

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?

Web app session publishes message
set JMSReplyTo header on the message to: temp-queue://ORDER.$jSessionId
setup a consumer on temp-queue://ORDER.$jSessionId
send to -> queue://PROCESS.ORDER
On the REST service
Consume from queue://PROCESS.ORDER
Do stuff with message
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

Related

Spring Integration with consumer and Nifi as dispatcher

we are developing a service that listens or consume message from RabbitMQ queue. The message is dispatch from Apache Nifi to the message queue (e.g. queue name is "workitems").
Now, I would like to see a code snippet using Spring Integration to listen and process this message dispatched in the queue (RabbitMQ) from Apache Nifi.
Thanks!
It sounds like you need AMQP Channel Adapter from Spring Integration: https://docs.spring.io/spring-integration/docs/5.3.0.M4/reference/html/amqp.html#amqp-inbound-channel-adapter
And here is a sample on the matter: https://github.com/spring-projects/spring-integration-samples/tree/master/basic/amqp

Spring web services, JMS transport and replay-to

I need to send a soap message to a queue and wait for the response into another.
The correlationId in the second one (the response queue) is the message Id in the first the message send to the request queue.
I'd like to use spring-ws but I am out of ideas. Could you please give me some advice or small example?
You can use spring integration like this example https://github.com/snicoll/scratches/blob/master/jms-request-reply/src/main/java/net/nicoll/scratch/spring/boot/jms/sync/JmsRequestReply.java
Or spring jms to do request-reply http://docs.spring.io/spring/docs/current/spring-framework-reference/html/jms.html

Send Active MQ messages throught Camel that were sent to a AMQ topic while Camel was down

I have configured an Active MQ server that puts messages to a determined topic, in that moment a configured Camel server take this message and send it by a route to another server, the issue happens when Camel server is down and the Active MQ still continues putting messages in the topic and when Camel starts these past messages are not read by Camel, is there any way to configure Camel to start and read past messages from this Active MQ Server?
Its ActiveMQ / JMS questions. Take a look at durable topics
http://activemq.apache.org/how-do-durable-queues-and-topics-work.html

Spring Stomp message send and receiptId

What is the right way to configure Spring StompBrokerRelay, to be able to create a simple java client which just publishes a messages, which are acknowledge by the server.
Spring client StompSession is returning Receiptable when sending message from client and it's possible to configure ReceiptTasks, but the receipt is never received from server.

Receiving messages from WSO2 Message Broker with Process Server

I successfully configured WSO2 Message Broker as a JMS server. I have configured WSO2 ESB to send messages to a queue, and I can see this queue get created in MB with messages.
Now, I want to consume those messages with Process Server and kick off a BPEL process. I have added the required libraries to components/lib in both ESB and BPS, and have created an identical jndi.properties in both. The URL for both ESB and BPEL is:
jms:/newMLECaseQueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory&java.naming.provider.url=repository/conf/jndi.properties&transport.jms.DestinationType=queue
I have tested a similar configuration with ActiveMQ, and there BPEL succesfully picked up the messages. In MB it does not seem to work, while the logging mentions that JMS started to listen:
Started to listen on destination : newMLECaseQueue of type queue for service newMLECaseQueue {org.apache.axis2.transport.jms.JMSListener}
What can be wrong here?
It appears that each queue must be registered using jndi.properties: when adding the queue with the line:
queue.newMLECaseQueue = newMLECaseQueue
it all started to work.

Resources