1

Given a queue in ActiveMQ with 50+ consumers, Is there a way to dispatch at the most 1 event per second to consumer? This is to control a flood of events dispatch.

Event producers are outside my application. Hence I need to handle the controlled dispatch from consumers side.
I have a jms prefetch policy configured to as low as 5. I do not want to dispatch 100's of messages to consumers in a span of few seconds. Instead I want it to be a steady flow.

How do I configure the Queue consumers to dispatch in a controlled flow?

1
  • You should consider to create another middleware for this throttling. Commented Dec 10, 2017 at 13:45

1 Answer 1

2
+50

As far as I know, there is no way to throttle the Consumers.

What you can do is to limit the flow to the consumer queue using built in Camel-routes. Maybe you can find a way to use this feature for your case?

  1. copy examples/camel.xml to your conf folder.
  2. edit the connection factory in the camel.xml file. In a default setup, change broker uri to vm://localhost?create=false
  3. include camel.xml in your activemq.xml <include resource="camel.xml"/>

Edit the route in camel.xml to something like this (1msg/1000ms)

 <route> <description>Throttler 1 msg/s</description> <from uri="activemq:msgs.in"/> <throttle timePeriodMillis="1000" asyncDelayed="true"> <constant>1</constant> <to uri="activemq:msgs.out"/> </throttle> </route> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.