Spring Jms ActiveMQ – How to create a SpringBoot ActiveMQ Response Management
Male avatar

loveprogramming viết ngày 06/05/2021

https://grokonez.com/spring-framework/spring-jms/activemq-create-springboot-activemq-response-management-application-sendto-annotation

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:

I. Technologies

– Java 8
– Maven 3.6.1
– Spring Tool Suite: Version 3.8.4.RELEASE
– Spring Boot: 1.5.4.RELEASE
– Apache ActiveMQ 5.14.0

II. ActiveMQ Response Management

With the Spring JMS improvements (from 4.1), we can used @SendTo annotation to define the default next destination with @JmsListener:

SpringBoot ActiveMQ Response Management application - sendto aannotation - architecture


@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;  
}
When having several @JmsListener methods, we can also place the @SendTo annotation at the class level to share a default reply destination.

III. Practice

In the tutorial, we create 2 SpringBoot projects {SpringActiveMqProducerConsumer, SpringActiveMqSendTo}:

SpringBoot ActiveMQ Response Management application - sendto aannotation - project structure

MORE AT:

https://grokonez.com/spring-framework/spring-jms/activemq-create-springboot-activemq-response-management-application-sendto-annotation

Spring Jms ActiveMQ – How to create a SpringBoot ActiveMQ Response Management application by @SendTo annotation

Bình luận


White
{{ comment.user.name }}
Bỏ hay Hay
{{comment.like_count}}
Male avatar
{{ comment_error }}
Hủy
   

Hiển thị thử

Chỉnh sửa

Male avatar

loveprogramming

545 bài viết.
98 người follow
Kipalog
{{userFollowed ? 'Following' : 'Follow'}}
Cùng một tác giả
Male avatar
1 0
Tutorial Link: (Link) (Ảnh) Django is a Pythonbased free and opensource web framework that follows the modeltemplateview architectural pattern. A...
loveprogramming viết 7 tháng trước
1 0
Male avatar
1 0
https://loizenai.com/angular11nodejspostgresqlcrudexample/ Angular 11 Node.js PostgreSQL Crud Example (Ảnh) Tutorial: “Angular 11 Node.js Postg...
loveprogramming viết 6 tháng trước
1 0
Male avatar
1 0
Angular Spring Boot jwt Authentication Example Github https://loizenai.com/angularspringbootjwt/ (Ảnh) Tutorial: ” Angular Spring Boot jwt Authe...
loveprogramming viết 6 tháng trước
1 0
{{like_count}}

kipalog

{{ comment_count }}

bình luận

{{liked ? "Đã kipalog" : "Kipalog"}}


Male avatar
{{userFollowed ? 'Following' : 'Follow'}}
545 bài viết.
98 người follow

 Đầu mục bài viết

Vẫn còn nữa! x

Kipalog vẫn còn rất nhiều bài viết hay và chủ đề thú vị chờ bạn khám phá!