Question

I would like to configure my ActiveMQ producers to failover (I'm using the Stomp protocol) when a broker reaches a configured limit. I want to allow consumers to continue consumption from the overloaded broker, unabated.

Reading ActiveMQ docs, it looks like I can configure ActiveMQ to do one of a few things when a broker reaches its limits (memory or disk):

  1. Slow down messages using producerFlowControl="true" (by blocking the send)
  2. Throw exceptions when using sendFailIfNoSpace="true"
  3. Neither of the above, in which case..I'm not sure what happens? Reverts to TCP flow control?

It doesn't look like any of these things are designed to trigger a producer failover. A producer will failover when it fails to connect but not, as far as I can tell, when it fails to send (due to producer flow control, for example).

So, is it possible for me to configure a broker to refuse connections when it reaches its limits? Or is my best bet to detect slow down on the producer side, and to manually reconfigure my producers to use the a different broker at that time?

Thanks!

Was it helpful?

Solution

Your best bet is to use sendFailIfNoSpace, or better sendFailIfNoSpaceAfterTimeout. This will throw an exception up to your client, which can then attempt to resend the message to another broker at the application level (though you can encapsulate this logic over the top of your Stomp library, and use this facade from your code). Though if your ActiveMQ setup is correctly wired, your load both in terms of production and consumption should be more or less evenly distributed across your brokers, so this feature may not buy you a great deal.

You would probably get a better result if you concentrated on fast consumption of the messages, and increased the storage limits to smooth out peaks in load.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top