I am developing a Spring JMS based client, which connects to an IBM MQ.
This part is working fine !!
Scenario:
The MQ client can get a request from multiple Spring "@Components". Considering, JMSTemplate's "send" and "receive" are completely different methods -
Question:
How do we co-relate the response from component-one to only its request ? e.g.
A sends request-A
B sends request-B
How will SpringListener know to respond the response-A to A, and response-B to B ?
Does spring provide an out of box functionality to handle such a scenario ?
Thanks in advance !!
Sample Listener :
public class MessageReceiver implements MessageListener {
@Override
public void onMessage(Message message) {
if(message instanceof TextMessage){
System.out.println(message.toString());
}
}
}
Sample Sender :
public class App
{
public static void main( String[] args )
{
ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
JmsTemplate jmsTemplate = (JmsTemplate)context.getBean("jmsTemplate");
jmsTemplate.send(s -> s.createTextMessage("TestingAMQ"));
}
}
Found this to be the approach of 'setProperty' -
https://codedependents.com/2010/03/04/synchronous-request-response-with-activemq-and-spring/