Solace Community is getting a facelift!
On March 3rd we will be starting the process of migrating Solace Community to a new platform. As a result, Solace Community will go in to a temporary read-only state. You will still be able to come onto Solace Community and search through posts to find answers, but you won't be able to ask questions, post comments, or react in any way.
We hope to have the migration complete by Wednesday March 5th (or sooner), so please keep an eye out!
How to integration test Solace with Spring Boot AutoConfig / JmsListener
Hello
the project I'm working on needs me to integrate a receiver for Solace PubSub+ Messages with Spring Boot. The following snippet resembles my current implementation. The controller receives a message, forwards it to my usecase which extracts some headers and the payload and creates a MyMessage POJO which in turn is finally handed back to the controller.
@Component @RequiredArgsConstructor public class MyController { private final MyUseCase myUseCase; @JmsListener(destination = "MyQueue") public MyMessage forward(Message<byte[]> message) { return this.myUseCase.handle(message); } }
The PubSub+ broker runs on Docker and has "MyQueue" configured.
Running the application and manually sending a Message on MyQueue shows that the controller is working as intended. We're running JUnit5 and Spring's MockMVC for our other controllers.
How can I test this controller with integration tests?
I see that I need a sender that posts a message on MyQueue which is then received by MyController. But how can I be sure that my Listener receives and forwards the message?
Is there a way to 'intercept' the returned MyMessage and evaluate it's fields?
Best Answer
-
Hi @rothek,
Can you take a look at Gary's answer here and see if it gives you what you need: https://stackoverflow.com/questions/42803627/writing-tests-to-verify-received-msg-in-jms-listener-spring-boot
1
Answers
-
Hi @rothek,
Can you take a look at Gary's answer here and see if it gives you what you need: https://stackoverflow.com/questions/42803627/writing-tests-to-verify-received-msg-in-jms-listener-spring-boot
1