activeMQ topic flooding

2019-05-11 22:29发布

问题:

Running ActiveMQ 5.4.0. I have a group of users that subscribe and publish to each other on various topics through a common ActiveMQ JMS provider. After a while of activity, the ActiveMQ console starts displaying

INFO|USAGE MANAGER memory limit reached. Stopping producer (ID ...... to prevent flooding topic .....

This message occurs repeatedly for various topics. I know that in some cases, some messages are never delivered. None of the producers on the 'net' are implementing any kind of flow control. They just send and forget. Obviously, some of the producers are being blocked, but most eventually break free. I believe the topics are non-durable/non-persistent.

I'm just using the default activemq configuration. So, how best to fix this problem? Is it wise to disable flow control and how?

回答1:

If you're using the default ActiveMQ configuration, flow control is on. This is why you're getting those messages.

If you don't want to use flow control you could do something like this:

<policyEntry topic="myTopic" producerFlowControl="false">

What this will do is use as much memory as ActiveMQ has to give you. Be aware, however, that at some point ActiveMQ will start spooling messages through the disk if it thinks you could cause problems for other queues, etc - this will effect performance because it's hitting the disks. This is completely separate from persistence. However if you have set a reasonable heap limit for java on startup in comparison to your total data needs, you should be ok.

Note that if you want to tell it not to spool through the disk, you do have to use flow control and have to set a max in memory size such as:

<policyEntry topic="myTopic" producerFlowControl="true" memoryLimit="200mb">
    <pendingQueuePolicy>
    <vmQueueCursor/>
</pendingQueuePolicy>
</policyEntry>

That would not use the disk, and block producers when the memoryLimit is hit. Again, you should be able to tailor this so it works for your configuration.

For more info on flow control: http://activemq.apache.org/producer-flow-control.html



标签: jms activemq