Wildfly 10.1.0.Final activemq.artemis load balancing (rebalancing)
dkjeldgaard Mar 15, 2017 5:45 PMHow can I configure activemq artemis to resolve the following problem.
I have a clustered Wildfly instance with 4 servers. Each server has a pool of MDBeans listening to a queue defined in the domain.xml messaging-activemq subsystem. Our application sends a large number of messages to the queue which then distributes them evenly across the 4 servers. The problem I'm having is that if one of the servers finishes consuming all of it's messages before another server, I'd like activemq.artemis the starving consumers on the server that finished to be able to pull some messages from the servers that are still processing. Likewise, if we start up another server we'd like activemq-artemis to start redistributing some messages to the newly available server. The nature of our application is such that different messages can take drastically different amounts of time to process, so some server queues can get backed up while others starve. We need a way to recognize starving consumers and redistribute messages to them. In the following configuration we are using the PASNettingProcessorQueue...
<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
<server name="default">
<security enabled="false"/>
<cluster password="${jboss.messaging.cluster.password:defaultPWD}"/>
<security-setting name="#">
<role name="guest" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true"/>
<role name="bpc" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true"/>
</security-setting>
<address-setting name="#" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" redelivery-delay="5000" max-delivery-attempts="5"/>
<address-setting name="jms.queue.BPCLoggingQueue" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" max-delivery-attempts="1"/>
<address-setting name="jms.queue.PASNettingProcessorQueue" max-delivery-attempts="1"/>
<http-connector name="http-connector" socket-binding="http" endpoint="http-acceptor"/>
<http-connector name="http-connector-throughput" socket-binding="http" endpoint="http-acceptor-throughput">
<param name="batch-delay" value="50"/>
</http-connector>
<in-vm-connector name="in-vm" server-id="0"/>
<http-acceptor name="http-acceptor" http-listener="default"/>
<http-acceptor name="http-acceptor-throughput" http-listener="default">
<param name="batch-delay" value="50"/>
<param name="direct-deliver" value="false"/>
</http-acceptor>
<in-vm-acceptor name="in-vm" server-id="0"/>
<broadcast-group name="bg-group1" jgroups-channel="activemq-cluster" connectors="http-connector"/>
<discovery-group name="dg-group1" jgroups-channel="activemq-cluster"/>
<cluster-connection name="my-cluster" address="jms" connector-name="http-connector" discovery-group="dg-group1"/>
<jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>
<jms-queue name="BPCLoggingQueue" entries="java:jboss/exported/jms/queue/BPCLoggingQueue" durable="false"/>
<jms-queue name="PASNettingProcessorQueue" entries="java:jboss/exported/jms/queue/PASNettingProcessorQueue" durable="false"/>
<connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
<connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector" ha="true" block-on-acknowledge="true" reconnect-attempts="-1"/>
<pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm" transaction="xa"/>
</server>
</subsystem>