Skip to content

Files

Latest commit

2f88c61 · Nov 15, 2016

History

History

worksheet2

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Networking Brokers

Prerequisites

  • worksheet1

  • A loopback address configured

    route add -net 224.0.0.0 netmask 240.0.0.0 dev lo

Creating 2 Clustered Brokers

  • create broker 1
(A_MQ_Install_Dir)/bin/artemis create  --user admin --password password --role admin --allow-anonymous y --clustered --host 127.0.0.1 --cluster-user clusterUser --cluster-password clusterPassword  --max-hops 1 broker1
  • create broker 2
(A_MQ_Install_Dir)/bin/artemis create  --user admin --password password --role admin --allow-anonymous y --clustered --host 127.0.0.1 --cluster-user clusterUser --cluster-password clusterPassword  --max-hops 1 --port-offset 100 broker2
  • start both brokers
(broker1_home)/bin/artemis run
(broker2_home)/bin/artemis run

After some initial negotiation you should see each broker log that a bridge has been created.

clustering a queue

Both brokers need to be configured with the same anycast queue definition

  • stop both brokers

  • Add an anycast queue configuration for both brokers

  <addresses>
     <address name="exampleQueue" type="anycast">
        <queues>
           <queue name="exampleQueue"/>
        </queues>
     </address>
  </addresses>
  • from the worksheet2 directory run 2 consumers connected to each broker
mvn verify -PqueueReceiver1
mvn verify -PqueueReceiver2                                      
  • from the worksheet2 directory run a producer to send 10 messages
mvn verify -PqueueSender

NB you will see each consumer receives 5 messages in a round robin fashion

  • kill the consumers and run the producer again
mvn verify -PqueueSender
  • now run the consumers again
mvn verify -PqueueReceiver1
mvn verify -PqueueReceiver2                                      

NB you will see that only 1 consumer received the messages as they were load balanced on demand.

  • now stop the brokers and update the load balancing to strict in the broker.xml file
<message-load-balancing>STRICT</message-load-balancing>
  • now re run the exercise and notice that both the consumers receive messages even when disconnected.

clustering a topic

Both brokers need to be configured with the same multicast topic definition

  • Add an multicast topic configuration for both brokers
  <addresses>
     <address name="exampleTopic" type="multicast"/>
   </addresses>
  • from the worksheet2 directory run 2 consumers connected to each broker
mvn verify -PtopicReceiver1
mvn verify -PtopicReceiver2                                      
  • from the worksheet2 directory run a producer to send 10 messages
mvn verify -PtopicSender

NB you will see each consumer receives all 10 messages