How to integration test Solace with Spring Boot AutoConfig / JmsListener


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.

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