Spring Jms ActiveMQ – How to create a SpringBoot ActiveMQ Response Management application by @SendTo annotation
In the past posts, we had learned how to consume/produce ActiveMq JMS messages. Today, JavaSampleApproach will show you way to create a SpringBoot ActiveMQ Response Management application by @SendTo
annotation.
Related posts:
@SendTo
annotation to define the default next destination with @JmsListener
:
@JmsListener(destination = "${jsa.activemq.queue.listen}", containerFactory="jsaFactory")
@SendTo("${jsa.activemq.queue.sendto}")
public Product processOrder(Product product) {
// process a newProduct
return newProduct;
}
For additional headers, you could return a Message object instead:
@JmsListener(destination = "${jsa.activemq.queue.listen}", containerFactory="jsaFactory")
@SendTo("${jsa.activemq.queue.sendto}")
public Message receive(Product product, @Header("company") String companyName){
...
Message mesage = MessageBuilder
.withPayload(product)
.setHeader("type", product.getType())
.build();
return mesage;
}
@JmsListener
methods, we can also place the @SendTo
annotation at the class level to share a default reply destination.
MORE AT:
Spring Jms ActiveMQ – How to create a SpringBoot ActiveMQ Response Management application by @SendTo annotation
#springjma #springboot #activemq #sendto