Message redistribution on ArtemisMQ 2.x does not w

2019-08-02 02:17发布

问题:

I would like to enable message redistribution on my 2-nodes cluster with static hosts. But it does not seem to work.

1) I have 10 producers that write to the queue "MyTestQueue" on node 1 (but no consumers).
2) I have 1 consumer on node 2 (but no producers) that consumes messages from node 2.

I expect that node 1 will redistribute the messages to node 2 where the consumer exists, but it does not. The message count on node 1 is still equal the amount of messages that was sent to node 1.

I have the following configuration in my broker.xml that sets forward-when-no-consumers to false. I also have set redistribution-delay to a value of zero.

<jms xmlns="urn:activemq:jms">
    <queue name="MyTestQueue"/>
</jms>
...
<cluster-connections>
      <cluster-connection name="my-test-cluster">
           <address>jms</address>
           <connector-ref>server0-connector</connector-ref>
            <retry-interval>500</retry-interval>
            <use-duplicate-detection>true</use-duplicate-detection>
            <forward-when-no-consumers>false</forward-when-no-consumers>
            <message-load-balancing>ON_DEMAND</message-load-balancing>
            <max-hops>1</max-hops>
            <confirmation-window-size>1024</confirmation-window-size>
            <static-connectors>
                <connector-ref>server1-connector</connector-ref>
            </static-connectors>
        </cluster-connection>
    </cluster-connections>
    ...
    <address-settings>
         <address-setting match="#">
             <redelivery-delay>5000</redelivery-delay>
             <redelivery-delay-multiplier>3</redelivery-delay-multiplier>
             <max-redelivery-delay>10000</max-redelivery-delay>
             <max-delivery-attempts>10</max-delivery-attempts>
             <max-size-bytes>104857600</max-size-bytes>
             <page-size-bytes>10485760</page-size-bytes>
             <address-full-policy>PAGE</address-full-policy>
             <redistribution-delay>0</redistribution-delay>
        </address-setting>
    </address-settings>

How can I get the message redistribution to work?

回答1:

This might be related to a known issue. There is a situation on which the broker fails to load balance the messages if they don't contain the application properties field.

Could you, please, try with that?



回答2:

Couple of things...

  • What version of Artemis are you using? Have you tried reproducing this with version 2.2.0?
  • What kind of client are you using (e.g. JMS, AMQP, STOMP, etc.)?
  • Do you have a reproducible test-case (e.g. a modified version of one of the examples shipped with Artemis)?
  • The configuration element <forward-when-no-consumers> is not valid in Artemis (although it was in older versions of HornetQ).


回答3:

Remove the <address>jms</address> from cluster connection configuration - each cluster connection only applies to addresses that match the specified address. And make sure that you're using compatible client because messages from 1.x clients to 2.x cluster are lost when the are load balanced to nodes with matching consumers.

Here's official, working example of ActiveMQ Artemis configuration with symmetric cluster, on demand load balancing and message redistribution