Some of the capabilities listed in these pages for Dispatch are for future releases and are supplied for the purpose of illustrating the potential of a message router. This section outlines the actual capabilities of version 0.1:
Download and extract the source tar file:
$ wget http://people.apache.org/~tross/qpid-dispatch-0.1rc5/qpid-dispatch-0.1.tar.gz
$ tar -xzf qpid-dispatch-0.1.tar.gz
Source the build configuration:
$ cd qpid-dispatch-0.1
$ source config.sh
Build and test the package. This will create two directories: 'build' and 'install'. Dispatch will be built in the 'build' directory and installed in the 'install' directory. The regression and system test suites will then be run against the installed bits.
$ bin/test.sh
If you wish to change the build configuration, go into the build directory, use cmake to configure your build then rebuild and/or reinstall from there:
$ cd build
$ cmake ..
$ make
$ make install
The default configuration file is installed in _install-prefix_/etc/qpid/qdrouterd.conf. This configuration file will cause the router to run in standalone mode, listening on the standard AMQP port (5672). Dispatch Router looks for the configuration file in the installed location by default. If you wish to use a different path, the "-c" command line option will instruct Dispatch Router as to which configuration to load.
To run the router, invoke the executable:
$ qdrouterd
Dispatch Router should, in theory, work with any client that is compatible with AMQP 1.0. The following clients have been tested:
Client | Notes |
---|---|
qpid::messaging | The Qpid messaging clients work with Dispatch Router as long as they are configured to use the 1.0 version of the protocol. To enable AMQP 1.0 in the C++ client, use the {protocol:amqp1.0} connection option. |
Proton Messenger | Messenger works with Dispatch Router. |
Installed with the Dispatch Router kit is a command line tool called qdstat. This tool can be used to view manageable data inside Dispatch Router. The following options are useful for seeing that the router is doing:
Option | Description |
---|---|
-l | Print a list of AMQP links attached to the router. Links are unidirectional. Outgoing links are usually associated with a subscription address. The tool distinguishes between _endpoint_ links and _router_ links. Endpoint links are attached to clients using the router. Router links are attached to other routers in a network of routers. |
-a | Print a list of addresses known to the router. |
-n | Print a list of known routers in the network. |
-c | Print a list of connections to the router. |
The router can operate stand-alone or as a node in a network of routers. The mode is configured in the _router_ section of the configuration file. In stand-alone mode, the router does not attempt to collaborate with any other routers and only routes messages among directly connected endpoints.
If your router is running in stand-alone mode, _qdstat -a_ will look like the following:
$ qdstat -a
Router Addresses
class address in-proc local remote in out thru to-proc from-proc
===============================================================================
local $management Y 0 0 1 0 0 1 0
local temp.AY81ga 1 0 0 0 0 0 0
Note that there are two known addresses. _$management_ is the address of the router's embedded management agent. _temp.AY81ga_ is the temporary reply-to address of the _qdstat_ client making requests to the agent.
If you change the mode to interior and restart the processs, the same command will yield two additional addresses which are used for inter-router communication:
$ qdstat -a
Router Addresses
class address in-proc local remote in out thru to-proc from-proc
===============================================================================
local $management Y 0 0 1 0 0 1 0
local qdhello Y 0 0 0 0 0 0 3
local qdrouter Y 0 0 0 0 0 0 1
local temp.khOpGb 1 0 0 0 0 0 0
The term "mobile subscriber" simply refers to the fact that a client may connect to the router and subscribe to an address to receive messages sent to that address. No matter where in the network the subscriber attaches, the messages will be routed to the appropriate destination.
To illustrate a subscription on a stand-alone router, you can use the examples that are provided with Qpid Proton. Using the _recv.py_ example receiver:
$ recv.py amqp://0.0.0.0/my-address
This command creates a receiving link subscribed to the specified address. To verify the subscription:
$ qdstat -a
Router Addresses
class address in-proc local remote in out thru to-proc from-proc
================================================================================
local $management Y 0 0 1 0 0 1 0
mobile my-address 1 0 0 0 0 0 0
local temp.fDt8_a 1 0 0 0 0 0 0
You can then, in a separate command window, run a sender to produce messages to that address:
$ send.py -a amqp://0.0.0.0/my-address
Dynamic reply-to can be used to obtain a reply-to address that routes back to a client's receiving link regardless of how many hops it has to take to get there. To illustrate this feature, see below a simple program (written in C++ against the qpid::messaging API) that queries the management agent of the attached router for a list of other known routers' management addresses.
#include <qpid/messaging/Address.h>
#include <qpid/messaging/Connection.h>
#include <qpid/messaging/Message.h>
#include <qpid/messaging/Receiver.h>
#include <qpid/messaging/Sender.h>
#include <qpid/messaging/Session.h>
using namespace qpid::messaging;
using namespace qpid::types;
using std::stringstream;
using std::string;
int main() {
const char* url = "amqp:tcp:127.0.0.1:5672";
std::string connectionOptions = "{protocol:amqp1.0}";
Connection connection(url, connectionOptions);
connection.open();
Session session = connection.createSession();
Sender sender = session.createSender("mgmt");
// create reply receiver and get the reply-to address
Receiver receiver = session.createReceiver("#");
Address responseAddress = receiver.getAddress();
Message request;
request.setReplyTo(responseAddress);
request.setProperty("x-amqp-to", "amqp:/_local/$management");
request.setProperty("operation", "DISCOVER-MGMT-NODES");
request.setProperty("type", "org.amqp.management");
request.setProperty("name, "self");
sender.send(request);
Message response = receiver.fetch();
Variant content(response.getContentObject());
std::cout << "Response: " << content << std::endl << std::endl;
connection.close();
}
The equivalent program written in Python against the Proton Messenger API:
from proton import Messenger, Message
def main():
host = "0.0.0.0:5672"
messenger = Messenger()
messenger.start()
messenger.route("amqp:/*", "amqp://%s/$1" % host)
reply_subscription = messenger.subscribe("amqp:/#")
reply_address = reply_subscription.address
request = Message()
response = Message()
request.address = "amqp:/_local/$management"
request.reply_to = reply_address
request.properties = {u'operation' : u'DISCOVER-MGMT-NODES',
u'type' : u'org.amqp.management',
u'name' : u'self'}
messenger.put(request)
messenger.send()
messenger.recv()
messenger.get(response)
print "Response: %r" % response.body
messenger.stop()
main()
This is an early test release. It is expected that users will find bugs and other various instabilities. The main goal of this release is to prove that the process can be run and that users can demonstrate basic functionality as described in this document. Nevertheless, the following are known issues with the 0.1 release:
Apache Qpid, Messaging built on AMQP; Copyright © 2015 The Apache Software Foundation; Licensed under the Apache License, Version 2.0; Apache Qpid, Qpid, Qpid Proton, Proton, Apache, the Apache feather logo, and the Apache Qpid project logo are trademarks of The Apache Software Foundation; All other marks mentioned may be trademarks or registered trademarks of their respective owners