Spring DefaultMessageListenerContainer and ActiveMQ

I configured Spring DefaultMessageListenerContainer as ActiveMQ consumer consumer messages from the queue. Let me call it “Test.Queue”. I have this code deployed on 4 different machines, and all the machines are configured on the same ActiveMQ instance to process messages from the same “Test.Queue” queue.

I set the maximum consumer size to 20, as soon as all 4 machines are up and running, I see that the number of consumers is counted up to 80 as the queue (the size of the maximum size is 4 * max = 80)

It’s all right when messages created and sent to the queue get tall.

When there are 1000 messages and among 80 consumers, say one of them is stuck, it freezes Active MQ to stop sending messages to other users.

All messages are stuck in ActiveMQ forever.

Since I have 4 cars with up to 80 consumers, I have no idea which consumer could not confirm.

I stop and restart all 4 machines, and when I stop a machine that has a bad consumer that is stuck, messages start to flow again.

I do not know how to configure DefaultMessageListenerContainer to reject a bad consumer and immediately signal ActiveMQ to start sending messages.

I was able to create a script even without Spring as follows:

  • I released up to 5000 messages and sent them to the "Test.Queue" queue
  • 2 (Consumer A, B) B onMessage(), ( Thread.sleep(Long.MAX_VALUE)), , , % 13 0, .

  • 2 .

  • Active MQ , 2 .
  • A B
  • B onMessage(), Thread , % 13 0.
  • B
  • - MQ, , 2, .
  • C .
  • ActiveMQ 3 2.
  • Consumer C , , , , B .
  • , Consumer A
  • B, .

, A, B, C Spring DefaultMessageListenerContainer, Spring DefaultMessageListenerContainer, ( B) , X- , , .

.

, .

+5
1

...

+2

All Articles