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

Answers

This Month's Leaders

This Week's Leaders