Chapter 2. Getting started
This section shows you how to install AMQ Interconnect on a single host, start the router with the default configuration settings, and distribute messages between two clients.
2.1. Installing AMQ Interconnect Copy linkLink copied to clipboard!
AMQ Interconnect 1.5 is distributed as a set of RPM packages, which are available through your Red Hat subscription.
Procedure
Ensure your subscription has been activated and your system is registered.
For more information about using the Customer Portal to activate your Red Hat subscription and register your system for packages, see Appendix B, Using your subscription.
Subscribe to the required repositories:
- Red Hat Enterprise Linux 6
$ sudo subscription-manager repos --enable=amq-interconnect-1-for-rhel-6-server-rpms --enable=amq-clients-2-for-rhel-6-server-rpms- Red Hat Enterprise Linux 7
$ sudo subscription-manager repos --enable=amq-interconnect-1-for-rhel-7-server-rpms --enable=amq-clients-2-for-rhel-7-server-rpms- Red Hat Enterprise Linux 8
$ sudo subscription-manager repos --enable=amq-interconnect-1-for-rhel-8-x86_64-rpms --enable=amq-clients-2-for-rhel-8-x86_64-rpmsUse the
yumordnfcommand to install theqpid-dispatch-router,qpid-dispatch-tools, andqpid-dispatch-consolepackages and their dependencies:$ sudo yum install qpid-dispatch-router qpid-dispatch-tools qpid-dispatch-consoleUse the
whichcommand to verify that theqdrouterdexecutable is present.$ which qdrouterd /usr/sbin/qdrouterdThe
qdrouterdexecutable should be located at/usr/sbin/qdrouterd.
2.2. Viewing the default router configuration file Copy linkLink copied to clipboard!
The router’s configuration file (qdrouterd.conf) controls the way in which the router functions. The default configuration file contains the minimum number of settings required for the router to run. As you become more familiar with the router, you can add to or change these settings, or create your own configuration files.
By default, the router configuration file defines the following settings for the router:
- Operating mode
- How it listens for incoming connections
- Routing patterns for the message routing mechanism
Procedure
Open the following file:
/etc/qpid-dispatch/qdrouterd.conf.When AMQ Interconnect is installed,
qdrouterd.confis installed in this directory. When the router is started, it runs with the settings defined in this file.Review the default settings in
qdrouterd.conf.Default Configuration File
router { mode: standalone1 id: Router.A2 } listener {3 host: 0.0.0.0 port: amqp authenticatePeer: no } address {4 prefix: closest distribution: closest } address { prefix: multicast distribution: multicast } address { prefix: unicast distribution: closest } address { prefix: exclusive distribution: closest } address { prefix: broadcast distribution: multicast }- 1
- By default, the router operates in standalone mode. This means that it can only communicate with endpoints that are directly connected to it. It cannot connect to other routers, or participate in a router network.
- 2
- The unique identifier of the router. This ID is used as the
container-id(container name) at the AMQP protocol level. If it is not specified, the router shall generate a random identifier at startup. - 3
- The
listenerentity handles incoming connections from client endpoints. By default, the router listens on all network interfaces on the default AMQP port (5672). - 4
- By default, the router is configured to use the message routing mechanism. Each
addressentity defines how messages that are received with a particular addressprefixshould be distributed. For example, all messages with addresses that start withclosestwill be distributed using theclosestdistribution pattern.
NoteIf a client requests a message with an address that is not defined in the router’s configuration file, the
balanceddistribution pattern will be used automatically.
Additional resources
- For more information about the router configuration file (including available entities and attributes), see the qdrouterd man page.
2.3. Starting the router Copy linkLink copied to clipboard!
After installing AMQ Interconnect, you start the router by using the qdrouterd command.
Procedure
To start the router, use the
qdrouterdcommand.This example uses the default configuration to start the router as a daemon:
$ qdrouterd -dThe router starts, using the default configuration file stored at
/etc/qpid-dispatch/qdrouterd.conf.View the log to verify the router status:
$ qdstat --logThis 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 Fri May 20 09:38:03 2017 ROUTER (info) Router started in Standalone mode Fri May 20 09:38:03 2017 ROUTER (info) Router Core thread running. 0/Router.A Fri May 20 09:38:03 2017 ROUTER (info) In-process subscription M/$management Fri May 20 09:38:03 2017 AGENT (info) Activating management agent on $_management_internal Fri May 20 09:38:03 2017 ROUTER (info) In-process subscription L/$management Fri May 20 09:38:03 2017 ROUTER (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 (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 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
Additional resources
- The qdrouterd man page.
2.4. Sending test messages Copy linkLink copied to clipboard!
After starting the router, send some test messages to see how the router can connect two endpoints by distributing messages between them.
This procedure demonstrates a simple configuration consisting of a single router 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 procedure, so there is no "store and forward" mechanism in the middle. Instead, the messages flow from the sender, through the router, to the receiver only if the receiver is online, and the sender can confirm that the messages have arrived at their destination.
Prerequisites
AMQ Python must be installed. For more information, see Using the AMQ Python Client.
Procedure
Navigate to the AMQ Python examples directory.
$ cd <install-dir>/examples/python/- <install-dir>
- The directory where you installed AMQ Python.
Start the
simple_recv.pyreceiver client.$ python simple_recv.py -a 127.0.0.1:5672/examples -m 5This command starts the receiver and listens on the
examplesaddress (127.0.0.1:5672/examples). The receiver is also set to receive a maximum of five messages.NoteIn 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.
In a new terminal window, navigate to the Python examples directory and run the
simple_send.pyexample:$ cd <install-dir>/examples/python/ $ python simple_send.py -a 127.0.0.1:5672/examples -m 5This command sends five auto-generated messages to the
examplesaddress (127.0.0.1:5672/examples) and then confirms that they were delivered and acknowledged by the receiver:all messages confirmedVerify that the receiver client received the messages.
The receiver client should display the contents of the five messages:
{u'sequence': 1L} {u'sequence': 2L} {u'sequence': 3L} {u'sequence': 4L} {u'sequence': 5L}
2.5. Next steps Copy linkLink copied to clipboard!
After you successfully install a standalone router and use it to distribute messages between two clients, you can configure a router network topology and route messages.
- Configure a router network topology
- After configuring a single router, you can deploy additional routers and connect them together to form a router network. Router networks can be any arbitrary topology.
- Route messages through the router network
Regardless of the underlying router network topology, you can configure how you want messages to be routed through the router network.
- Configure addresses to specify routing patterns for direct-routed (brokerless) messaging
- Connect the router to a message broker to enable clients to exchange messages with a broker queue.
- Create link routes to define private messaging paths between endpoints.
For more information, see Chapter 5, Routing messages through the router network.