RabbitMQ Integration Test and Threading

前端 未结 1 922
陌清茗
陌清茗 2021-01-12 16:07

I have written a RabbitMQ consumer by implementing the MessageListener interface and setting up a SimpleMessageListenerContainer. Its working well when I test it manually. N

相关标签:
1条回答
  • 2021-01-12 16:47

    There are several approaches, the easiest being to wrap your listener and pass in a CountDownLatch which is counted down by the listener and the main test thread uses

    assertTrue(latch.await(TimeUnit.SECONDS));
    

    You can also pass back the actual message received so you can verify it is as expected.

    Also see the integration test cases in the framework itself.

    0 讨论(0)
提交回复
热议问题