Chapter 3. Getting Started
Before configuring AMQ Interconnect, you should understand how to start the router, how it is configured by default, and how to use it in a simple peer-to-peer configuration.
3.1. Starting the Router
Procedure
To start the router with the default configuration, do one of the following:
To… Enter this command… Run the router as a service in Red Hat Enterprise Linux 6
$ sudo service qdrouterd start
Run the router as a service in Red Hat Enterprise Linux 7
$ systemctl start qdrouterd.service
Run the router as a daemon
$ qdrouterd -d
To start the router in the foreground, do not use the
-d
parameter.NoteYou can specify a different configuration file with which to start the router. For more information, see Changing a Router’s Configuration.
The router starts, using the default configuration file stored at
/etc/qpid-dispatch/qdrouterd.conf
.View the log to verify the router status:
$ qdstat --log
This example shows that the router was correctly installed, is running, and is ready to route traffic between clients:
$ qdstat --log Fri May 20 09:38:03 2017 SERVER (info) Container Name: Router.A 1 Fri May 20 09:38:03 2017 ROUTER (info) Router started in Standalone mode 2 Fri May 20 09:38:03 2017 ROUTER_CORE (info) Router Core thread running. 0/Router.A Fri May 20 09:38:03 2017 ROUTER_CORE (info) In-process subscription M/$management Fri May 20 09:38:03 2017 AGENT (info) Activating management agent on $_management_internal 3 Fri May 20 09:38:03 2017 ROUTER_CORE (info) In-process subscription L/$management Fri May 20 09:38:03 2017 ROUTER_CORE (info) In-process subscription L/$_management_internal Fri May 20 09:38:03 2017 DISPLAYNAME (info) Activating DisplayNameService on $displayname Fri May 20 09:38:03 2017 ROUTER_CORE (info) In-process subscription L/$displayname Fri May 20 09:38:03 2017 CONN_MGR (info) Configured Listener: 0.0.0.0:amqp proto=any role=normal 4 Fri May 20 09:38:03 2017 POLICY (info) Policy configured maximumConnections: 0, policyFolder: '', access rules enabled: 'false' Fri May 20 09:38:03 2017 POLICY (info) Policy fallback defaultApplication is disabled Fri May 20 09:38:03 2017 SERVER (info) Operational, 4 Threads Running 5
- 1
- The name of this router instance.
- 2
- By default, the router starts in standalone mode, which means that it cannot connect to other routers or be used in a router network.
- 3
- The management agent. It provides the
$management
address, through which management tools such asqdmanage
andqdstat
can perform create, read, update, and delete (CRUD) operations on the router. As an AMQP endpoint, the management agent supports all operations defined by the AMQP management specification (Draft 9). - 4
- A listener is started on all available network interfaces and listens for connections on the standard AMQP port (5672, which is not encrypted).
- 5
- Threads for handling message traffic and all other internal operations.
3.2. Routing Messages in a Peer-to-Peer Configuration
This example demonstrates how the router can connect clients by receiving and sending messages between them. It uses the router’s default configuration file and does not require a broker.
Figure 3.1. Peer-to-peer Communication
As the diagram indicates, the configuration consists of an AMQ Interconnect component with two clients connected to it: a sender and a receiver. The receiver wants to receive messages on a specific address, and the sender sends messages to that address.
A broker is not used in this example, so there is no "store and forward" mechanism in the middle. Instead, the messages flow from sender to receiver only if the receiver is online, and the sender can confirm that the messages have arrived at their destination.
This example uses the AMQ Python client to start a receiver client, and then send five messages from the sender client.
Prerequisites
The AMQ Python client must be installed before you can complete the peer-to-peer routing example. For more information, see Installation in Using the AMQ Python Client.
Procedure
3.2.1. Starting the Receiver Client
In this example, the receiver client is started first. This means that the messages will be sent as soon as the sender client is started.
In practice, the order in which you start senders and receivers does not matter. In both cases, messages will be sent as soon as the receiver comes online.
Procedure
To start the receiver by using the Python receiver client, navigate to the Python examples directory and run the
simple_recv.py
example:$ cd INSTALL_DIR/examples/python/ $ python simple_recv.py -a 127.0.0.1:5672/examples -m 5
This command starts the receiver and listens on the default address (
127.0.0.1:5672/examples
). The receiver is also set to receive a maximum of five messages.
3.2.2. Sending Messages
After starting the receiver client, you can send messages from the sender. These messages will travel through the router to the receiver.
Procedure
In a new terminal window, navigate to the Python examples directory and run the
simple_send.py
example:$ cd INSTALL_DIR/examples/python/ $ python simple_send.py -a 127.0.0.1:5672/examples -m 5
This command sends five auto-generated messages to the default address (
127.0.0.1:5672/examples
) and then confirms that they were delivered and acknowledged by the receiver:all messages confirmed
The receiver client receives the messages and displays their content:
{u'sequence': 1L} {u'sequence': 2L} {u'sequence': 3L} {u'sequence': 4L} {u'sequence': 5L}