0

I see multiple examples demonstrating on how to test jms-listeners, but what i am really looking for is testing some negative test cases such as,

  1. test if jms transaction is rolled back if there is any error processing the message
  2. test if jms listener handles/throws exception

Below are some examples, which jst shows positive test cases,

How to wait for @JMSListener annotated method to complete in JUnit

Writing tests to verify received msg in jms listener (Spring-Boot)

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
rajcool111
  • 657
  • 4
  • 14
  • 36

1 Answers1

1

Use one of the positive test techniques to verify the listener actually received the message.

Then simply us JmsTemplate.receive() to verify the message was rolled back into the queue.

Or, if you are configured to send poison messages to a DLQ after some number of delivery attempts, you can simply receive from the DLQ in your test case.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179