Reputation: 645
I want to create two brokers that will sync with each other and their producers, consumers will see each other.
broker.xml
of server1:
<connectors>
<!-- Connector used to be announced through cluster connections and notifications -->
<connector name="artemis">tcp://localhost:61616</connector>
<!-- connector to the server2 -->
<connector name="server2-connector">tcp://localhost:61617</connector>
</connectors>
<cluster-user>admin</cluster-user>
<cluster-password>admin</cluster-password>
<!-- Clustering configuration -->
<cluster-connections>
<cluster-connection name="my-cluster">
<connector-ref>artemis</connector-ref>
<retry-interval>500</retry-interval>
<use-duplicate-detection>true</use-duplicate-detection>
<message-load-balancing>STRICT</message-load-balancing>
<max-hops>1</max-hops>
<static-connectors>
<connector-ref>server2-connector</connector-ref>
</static-connectors>
</cluster-connection>
</cluster-connections>
broker.xml
of server2:
<connectors>
<!-- Connector used to be announced through cluster connections and notifications -->
<connector name="artemis">tcp://localhost:61617</connector>
<!-- connector to the server1 -->
<connector name="server1-connector">tcp://localhost:61616</connector>
</connectors>
<cluster-user>admin</cluster-user>
<cluster-password>admin</cluster-password>
<!-- Clustering configuration -->
<cluster-connections>
<cluster-connection name="my-cluster">
<connector-ref>artemis</connector-ref>
<retry-interval>500</retry-interval>
<use-duplicate-detection>true</use-duplicate-detection>
<message-load-balancing>STRICT</message-load-balancing>
<max-hops>1</max-hops>
<static-connectors>
<connector-ref>server1-connector</connector-ref>
</static-connectors>
</cluster-connection>
</cluster-connections>
Messages created from web console of server1 is not visible in web console of server2. What's wrong with this configuration?
Status in web console:
Cluster Info
Lives: 2
Backups: 0
HA Policy: Live Only
Upvotes: 0
Views: 1379
Reputation: 35122
Live brokers in a cluster don't exactly "sync" with each other. You seem to expect that the console of every live broker in the cluster will report the same message statistics as every other live broker in the cluster. However, that's not how it works.
Each live broker in the cluster "owns" certain messages and each broker has an independent set of queues. Therefore, the web console for each broker will display the unique statistics for that particular broker. To be clear, messages can move from one broker to another so that consumers connected to one live broker in the cluster can potentially consume messages sent to a different live broker in the cluster, but the messages are just moved and not copied or reproduced in any way.
I recommend you take a look at the cluster documentation as it provides more details about how all this works.
If you want to "sync" one broker with another broker so that if the broker fails the other one will take over and have all the same message data then you should configure high availability with a live/backup pair of brokers. See the HA documentation for more details.
Upvotes: 0
Reputation: 777
Quoting from the official documentation:
Note that Apache ActiveMQ Artemis will not forward messages to other nodes if there are no queues of the same name on the other nodes, even if this parameter is set to STRICT.
Also note that clustering and high availability (HA) are distinct concepts.
Upvotes: 0