0

I have a JMSTemplate jmsT. To test it out, my only two lines of code are:

jmsT.convertAndSend("Location", "Message");
jmsT.receiveAndConvert("Location");

The code stalls at receiveAndConvert, waiting forever to receive a message as if it doesn't exist, despite that being exactly what the previous line creates.

adisplayname
  • 117
  • 1
  • 10

1 Answers1

1

If you are using an embedded ActiveMQ, you must use a CachingConnectionFactory. Otherwise the embedded broker will go away between the two calls.

DEBUG logging is always your friend.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • Would that also work if I had the convertAndSend and receiveAndConvert in different applications? – adisplayname Jul 27 '18 at 21:18
  • It's unusual to use an embedded broker to communicate between applications; you would normally have an external broker running. You can use an embedded broker but it would need to listen on a `tcp` transport instead of the `vm` transport. It's always a good idea to use a `CachingConnectionFactory` with a `JmsTemplate` for performance reasons. – Gary Russell Jul 28 '18 at 16:13