Over a million developers have joined DZone.

Quickly Integrate Interconnect/Qpid Dispatch Router With AMQ7.

DZone 's Guide to

Quickly Integrate Interconnect/Qpid Dispatch Router With AMQ7.

Let's take a look at how to quickly integrate a Qpid dispatch router with AMQ7. Also, explore how to set up and start AMQ7.

Free Resource

In this article, we will learn how to integrate Qpid Dispatch Router or Interconnect with AMQ7 or Apache Activemq Artemis. We will understand the basic router configuration for Interconnect to connect to AMQ7 broker. Interconnect is also known as Apache Qpid Dispatch Router or simply Dispatch Router.

We have a Docker image of Qpid Dispatch Router. This Docker image is just for testing the router configurations. Qpid Dispatch Router is provided as a set of rpms, which might be tricky to install. I don't suggest this Docker image to be used in a production environment as it is not enterprise ready. However, there should be a way where developers and the QE Team can test router configuration without diving deep into installation procedures. It also shouldn't be OS specific. With Docker image, one can directly spin up multiple router containers with different router configurations in few seconds. Also, it is OS independent. I can run this Dispatch Router in Ubuntu or CentOS or Fedora or other Linux flavors without any software installation, which might be a mess for beginners.

A major benefit we have with Dispatch Router is that there is a less number of connections to the broker. Clients only communicate with Dispatch Router with amqp protocol, clients are not aware of brokers onlyDispatch Router communicate with brokers. Hence, a less number of connections to the broker. Also, Dispatch Router provide High-Availability, what it means is if we have multiple Dispatch Router connected in a topology, even if one of Dispatch Routers is down, the other Dispatch Router will keep handling the traffic.

The following are the steps one should follow to have a Standalone Dispatch Router connected to AMQ7 broker.

Set up and Start AMQ7

We can download and setup AMQ7 or Apache ActiveMQ Artemis. Here, make sure that amqp port of AMQ7 broker instance is different than Dispatch Router. I changed the AMQ7 instance amqp port to 5673 so that it doesn't conflict with amqp port of Dispatch Router. It can be changed within AMQ7_Instance/etc/broker.xml

Create and Build Docker Image

A) Let us create a Docker image based on ceposta/qdr docker image. I named this docker file as DockerFile_QDR. We are also installing sasl-plain plugin so that we can pass plain credentials to access AMQ7 broker from router.

FROM ceposta/qdr
RUN yum -y install cyrus-sasl-plain

B) Build Docker image from the Docker file.

docker build -t qdr/saslplain -f ./DockerFile_QDR .

Set up Router Configuration

One can find the complete router configuration at my personal GitHub link.

Important sections in this file are router, address, listener, connector. More details here.

<strong>router</strong>: Attribute mode is set to standalone, which means it acts as a single node and doesn't cooperate with other routers.

<strong>address</strong>: Here foo is the address or destination.

<strong>listener</strong>: Router accepts amqp messages on port 5672.

<strong>autolink</strong>: Here dir with value In means into the router, out means out of the router. Also, addr is set as foo.

<strong>connector</strong>: Configuration here connect router to broker. We have set saslMechanisms as plain so that user can be authenticated in broker.

Run Docker Image With Router Configuration

Here are a couple of important points that we are using — net="host" so that the Docker container can see AMQ7 running in the host machine. Secondly, we are mounting router-to-broker.conf i.e. router configuration.

docker run --net="host" -it --rm --name qdr -p 5672:5672 -v /home/chandrashekhar/Development/DockerFiles/qpid-proton/router-to-broker.conf:/etc/qpid-dispatch/qdrouterd.conf qdr/saslplain

Send amqp Message to the Dispatch Router and Check Statistics in AMQ7 Broker

With help of AMQ7 script available within the bin folder of AMQ7 or the Artemis broker instance, we can produce and browse messages. Here, we can find that messages are being sent to Dispatch Router i.e. at URL tcp://localhost:5672 and protocol set to amqp. However, we are browsing message on AMQ7 listening on 61616 port.

./artemis producer --url tcp://localhost:5672 --message-count 1 --destination foo --protocol amqp --text-size 50
./artemis browser --url tcp://localhost:61616 --user admin --password admin --destination foo

Analyse Apache Qpid Dispatch Router Statistics

There is a different switch used with qdstat command to view router statistics.

-c, --connections Show Connections

-l, --links Show Router Links

-n, --nodes Show Router Nodes

-a, --address Show Router Addresses

$ docker container ls


e32798a88ee9 qdr/saslplain "/usr/sbin/qdrouterd…" 2 minutes ago Up 2 minutes

$ docker exec e32798a88ee9 qdstat -c

$ docker exec e32798a88ee9 qdstat -l

$ docker exec e32798a88ee9 qdstat -a

That's it! I believe this article will help you to start with Apache Qpid Dispatch Router. With the next article, we will establish multiple Apache Qpid Dispatch Routers to provide high availability with AMQ7.

amq7 router ,amqp ,integration ,docker ,qpid dispatch router

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}