Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
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: - Expand - To… - Enter this command… - Run the router as a service in Red Hat Enterprise Linux 6 - sudo service qdrouterd start - $ sudo service qdrouterd start- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Run the router as a service in Red Hat Enterprise Linux 7 - systemctl start qdrouterd.service - $ systemctl start qdrouterd.service- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Run the router as a daemon - qdrouterd -d - $ qdrouterd -d- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - To start the router in the foreground, do not use the - -dparameter.Note- You 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 - $ qdstat --log- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - This example shows that the router was correctly installed, is running, and is ready to route traffic between clients: - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 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$managementaddress, through which management tools such asqdmanageandqdstatcan 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.pyexample:- cd INSTALL_DIR/examples/python/ python simple_recv.py -a 127.0.0.1:5672/examples -m 5 - $ cd INSTALL_DIR/examples/python/ $ python simple_recv.py -a 127.0.0.1:5672/examples -m 5- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 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.pyexample:- cd INSTALL_DIR/examples/python/ python simple_send.py -a 127.0.0.1:5672/examples -m 5 - $ cd INSTALL_DIR/examples/python/ $ python simple_send.py -a 127.0.0.1:5672/examples -m 5- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 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 - all messages confirmed- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 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}- {u'sequence': 1L} {u'sequence': 2L} {u'sequence': 3L} {u'sequence': 4L} {u'sequence': 5L}- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
