How can I reduce the number of messages coming from ActiveMQ in my C # application?

I use ActiveMQ in a .NET program, and I have flooded it with event messages.

In short, when I get the event queue 'onMessage (IMessage receivedMsg)' I put the message in the internal queue from which the X-threads do their work.

At first I had: "AcknowledgementMode.AutoAcknowledge" when creating the session, so I assume that all messages in the queue were pulled and placed in the memory queue (which is risky because everything is lost with the crash).

So, I used: "AcknowledgementMode.ClientAcknowledge" when creating a session, and when the worker was ready with the message, it calls the "commit ()" method in the message. However, all messages are sucked out of the queue.

How can I configure it so that ONLY the number of messages X is processed or is in the internal queue, and that not everything is immediately "loaded"?

+5
source share
2 answers

Are you using .NET 4.0? You can use BlockingCollection. Set it to the maximum amount that it can contain. As soon as the thread tries to place an extra element, the Add operation will be blocked until the collection falls below the threshold.

Perhaps this would do it for throttling?

API Rx-, , . Observable, API , , .

+3

, . Auto Ack, onMessage . 1000 , , , , , . , , , onMessage , , , Auto Ack .

NMS : http://activemq.apache.org/nms/configuring.html

. FuseSource.com

+2

All Articles