From 47fb332cc91310afbb49af74b5d0f11b1efdaaa1 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 5 Mar 2012 21:31:58 +0000 Subject: QPID-3603: Initial documentation for the new HA plug-in. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1297234 13f79535-47bb-0310-9956-ffa450edef68 --- .../book/src/AMQP-Messaging-Broker-CPP-Book.xml | 37 +- qpid/doc/book/src/AMQP-Messaging-Broker-CPP.xml | 2 +- qpid/doc/book/src/Active-Active-Cluster.xml | 561 +++ qpid/doc/book/src/Active-Passive-Cluster.xml | 361 ++ qpid/doc/book/src/HA-Queue-Replication.xml | 54 + qpid/doc/book/src/Managing-CPP-Broker.xml | 39 +- qpid/doc/book/src/Programming-In-Apache-Qpid.xml | 4752 ++++++++++---------- qpid/doc/book/src/Starting-a-cluster.xml | 561 --- qpid/doc/book/src/schemas.xml | 175 +- 9 files changed, 3490 insertions(+), 3052 deletions(-) create mode 100644 qpid/doc/book/src/Active-Active-Cluster.xml create mode 100644 qpid/doc/book/src/Active-Passive-Cluster.xml create mode 100644 qpid/doc/book/src/HA-Queue-Replication.xml delete mode 100644 qpid/doc/book/src/Starting-a-cluster.xml (limited to 'qpid/doc') diff --git a/qpid/doc/book/src/AMQP-Messaging-Broker-CPP-Book.xml b/qpid/doc/book/src/AMQP-Messaging-Broker-CPP-Book.xml index 10d83ec887..228c6a5e15 100644 --- a/qpid/doc/book/src/AMQP-Messaging-Broker-CPP-Book.xml +++ b/qpid/doc/book/src/AMQP-Messaging-Broker-CPP-Book.xml @@ -20,7 +20,7 @@ --> - + AMQP Messaging Broker (Implemented in C++) Introduction @@ -46,21 +46,20 @@ Running the AMQP Messaging Broker - - - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -69,8 +68,8 @@ Managing the AMQP Messaging Broker - - - + + + diff --git a/qpid/doc/book/src/AMQP-Messaging-Broker-CPP.xml b/qpid/doc/book/src/AMQP-Messaging-Broker-CPP.xml index 92b474b0c0..b4e0deb13d 100644 --- a/qpid/doc/book/src/AMQP-Messaging-Broker-CPP.xml +++ b/qpid/doc/book/src/AMQP-Messaging-Broker-CPP.xml @@ -49,7 +49,7 @@ - + diff --git a/qpid/doc/book/src/Active-Active-Cluster.xml b/qpid/doc/book/src/Active-Active-Cluster.xml new file mode 100644 index 0000000000..28db3876e2 --- /dev/null +++ b/qpid/doc/book/src/Active-Active-Cluster.xml @@ -0,0 +1,561 @@ + + + +
+ Active-active Messaging Clusters + + Active-active Messaging Clusters provide fault tolerance by ensuring that every broker in a cluster has the same queues, exchanges, messages, and bindings, and allowing a client to fail over to a new broker and continue without any loss of messages if the current broker fails or becomes unavailable. Active-active refers to the fact that all brokers in the cluster can actively serve clients. Because all brokers are automatically kept in a consistent state, clients can connect to and use any broker in a cluster. Any number of messaging brokers can be run as one cluster, and brokers can be added to or removed from a cluster while it is in use. + + + High Availability Messaging Clusters are implemented using using the OpenAIS Cluster Framework. + + + An OpenAIS daemon runs on every machine in the cluster, and these daemons communicate using multicast on a particular address. Every qpidd process in a cluster joins a named group that is automatically synchronized using OpenAIS Closed Process Groups (CPG) — the qpidd processes multicast events to the named group, and CPG ensures that each qpidd process receives all the events in the same sequence. All members get an identical sequence of events, so they can all update their state consistently. + + + Two messaging brokers are in the same cluster if + + + + They run on hosts in the same OpenAIS cluster; that is, OpenAIS is configured with the same mcastaddr, mcastport and bindnetaddr, and + + + + + + They use the same cluster name. + + + + + + + + + High Availability Clustering has a cost: in order to allow each broker in a cluster to continue the work of any other broker, a cluster must replicate state for all brokers in the cluster. Because of this, the brokers in a cluster should normally be on a LAN; there should be fast and reliable connections between brokers. Even on a LAN, using multiple brokers in a cluster is somewhat slower than using a single broker without clustering. This may be counter-intuitive for people who are used to clustering in the context of High Performance Computing or High Throughput Computing, where clustering increases performance or throughput. + + + + High Availability Messaging Clusters should be used together with Red Hat Clustering Services (RHCS); without RHCS, clusters are vulnerable to the "split-brain" condition, in which a network failure splits the cluster into two sub-clusters that cannot communicate with each other. See the documentation on the --cluster-cman option for details on running using RHCS with High Availability Messaging Clusters. See the CMAN Wiki for more detail on CMAN and split-brain conditions. Use the --cluster-cman option to enable RHCS when starting the broker. + +
+ Starting a Broker in a Cluster + + Clustering is implemented using the cluster.so module, which is loaded by default when you start a broker. To run brokers in a cluster, make sure they all use the same OpenAIS mcastaddr, mcastport, and bindnetaddr. All brokers in a cluster must also have the same cluster name — specify the cluster name in qpidd.conf: + + + cluster-name="local_test_cluster" + + + On RHEL6, you must create the file /etc/corosync/uidgid.d/qpidd to tell Corosync the name of the user running the broker.By default, the user is qpidd: + + + + uidgid { + uid: qpidd + gid: qpidd + } + + + On RHEL5, the primary group for the process running qpidd must be the ais group. If you are running qpidd as a service, it is run as the qpidd user, which is already in the ais group. If you are running the broker from the command line, you must ensure that the primary group for the user running qpidd is ais. You can set the primary group using newgrp: + + + $ newgrp ais + + + You can then run the broker from the command line, specifying the cluster name as an option. + + + [jonathan@localhost]$ qpidd --cluster-name="local_test_cluster" + + + All brokers in a cluster must have identical configuration, with a few exceptions noted below. They must load the same set of plug-ins, and have matching configuration files and command line arguments. The should also have identical ACL files and SASL databases if these are used. If one broker uses persistence, all must use persistence — a mix of transient and persistent brokers is not allowed. Differences in configuration can cause brokers to exit the cluster. For instance, if different ACL settings allow a client to access a queue on broker A but not on broker B, then publishing to the queue will succeed on A and fail on B, so B will exit the cluster to prevent inconsistency. + + + The following settings can differ for brokers on a given cluster: + + + + + logging options + + + + + + cluster-url — if set, it will be different for each broker. + + + + + + port — brokers can listen on different ports. + + + + + + + The qpid log contains entries that record significant clustering events, e.g. when a broker becomes a member of a cluster, the membership of a cluster is changed, or an old journal is moved out of the way. For instance, the following message states that a broker has been added to a cluster as the first node: + + + + 2009-07-09 18:13:41 info 127.0.0.1:1410(READY) member update: 127.0.0.1:1410(member) + 2009-07-09 18:13:41 notice 127.0.0.1:1410(READY) first in cluster + + + + If you are using SELinux, the qpidd process and OpenAIS must have the same SELinux context, or else SELinux must be set to permissive mode. If both qpidd and OpenAIS are run as services, they have the same SELinux context. If both OpenAIS and qpidd are run as user processes, they have the same SELinux context. If one is run as a service, and the other is run as a user process, they have different SELinux contexts. + + + + + The following options are available for clustering: + + + Options for High Availability Messaging Cluster + + + + + + + Options for High Availability Messaging Cluster + + + + + + + + + --cluster-name NAME + + + Name of the Messaging Cluster to join. A Messaging Cluster consists of all brokers started with the same cluster-name and openais configuration. + + + + + + --cluster-size N + + + Wait for at least N initial members before completing cluster initialization and serving clients. Use this option in a persistent cluster so all brokers in a persistent cluster can exchange the status of their persistent store and do consistency checks before serving clients. + + + + + + --cluster-url URL + + + An AMQP URL containing the local address that the broker advertizes to clients for fail-over connections. This is different for each host. By default, all local addresses for the broker are advertized. You only need to set this if + + + + Your host has more than one active network interface, and + + + + + + You want to restrict client fail-over to a specific interface or interfaces. + + + + + + Each broker in the cluster is specified using the following form: + + url = ["amqp:"][ user ["/" password] "@" ] protocol_addr + ("," protocol_addr)* + protocol_addr = tcp_addr / rmda_addr / ssl_addr / ... + tcp_addr = ["tcp:"] host [":" port] + rdma_addr = "rdma:" host [":" port] + ssl_addr = "ssl:" host [":" port] + + In most cases, only one address is advertized, but more than one address can be specified in if the machine running the broker has more than one network interface card, and you want to allow clients to connect using multiple network interfaces. Use a comma delimiter (",") to separate brokers in the URL. Examples: + + + + amqp:tcp:192.168.1.103:5672 advertizes a single address to the broker for failover. + + + + + + amqp:tcp:192.168.1.103:5672,tcp:192.168.1.105:5672 advertizes two different addresses to the broker for failover, on two different network interfaces. + + + + + + + + + + + + --cluster-cman + + + + CMAN protects against the "split-brain" condition, in which a network failure splits the cluster into two sub-clusters that cannot communicate with each other. When "split-brain" occurs, each of the sub-clusters can access shared resources without knowledge of the other sub-cluster, resulting in corrupted cluster integrity. + + + To avoid "split-brain", CMAN uses the notion of a "quorum". If more than half the cluster nodes are active, the cluster has quorum and can act. If half (or fewer) nodes are active, the cluster does not have quorum, and all cluster activity is stopped. There are other ways to define the quorum for particular use cases (e.g. a cluster of only 2 members), see the CMAN Wiki + for more detail. + + + When enabled, the broker will wait until it belongs to a quorate cluster before accepting client connections. It continually monitors the quorum status and shuts down immediately if the node it runs on loses touch with the quorum. + + + + + + + + --cluster-username + + + SASL username for connections between brokers. + + + + + + --cluster-password + + + SASL password for connections between brokers. + + + + + + --cluster-mechanism + + + SASL authentication mechanism for connections between brokers + + + + + + + + +
+ + If a broker is unable to establish a connection to another broker in the cluster, the log will contain SASL errors, e.g: + + + 2009-aug-04 10:17:37 info SASL: Authentication failed: SASL(-13): user not found: Password verification failed + + + You can set the SASL user name and password used to connect to other brokers using the cluster-username and cluster-password properties when you start the broker. In most environment, it is easiest to create an account with the same user name and password on each broker in the cluster, and use these as the cluster-username and cluster-password. You can also set the SASL mode using cluster-mechanism. Remember that any mechanism you enable for broker-to-broker communication can also be used by a client, so do not enable cluster-mechanism=ANONYMOUS in a secure environment. + + + Once the cluster is running, run qpid-cluster to make sure that the brokers are running as one cluster. See the following section for details. + + + If the cluster is correctly configured, queues and messages are replicated to all brokers in the cluster, so an easy way to test the cluster is to run a program that routes messages to a queue on one broker, then to a different broker in the same cluster and read the messages to make sure they have been replicated. The drain and spout programs can be used for this test. + + +
+ +
+ qpid-cluster + + qpid-cluster is a command-line utility that allows you to view information on a cluster and its brokers, disconnect a client connection, shut down a broker in a cluster, or shut down the entire cluster. You can see the options using the --help option: + + + $ ./qpid-cluster --help + + + Usage: qpid-cluster [OPTIONS] [broker-addr] + + broker-addr is in the form: [username/password@] hostname | ip-address [:<port>] + ex: localhost, 10.1.1.7:10000, broker-host:10000, guest/guest@localhost + + Options: + -C [--all-connections] View client connections to all cluster members + -c [--connections] ID View client connections to specified member + -d [--del-connection] HOST:PORT + Disconnect a client connection + -s [--stop] ID Stop one member of the cluster by its ID + -k [--all-stop] Shut down the whole cluster + -f [--force] Suppress the 'are-you-sure?' prompt + -n [--numeric] Don't resolve names + + + Let's connect to a cluster and display basic information about the cluser and its brokers. When you connect to the cluster using qpid-tool, you can use the host and port for any broker in the cluster. For instance, if a broker in the cluster is running on localhost on port 6664, you can start qpid-tool like this: + + + + $ qpid-cluster localhost:6664 + + + Here is the output: + + + + Cluster Name: local_test_cluster + Cluster Status: ACTIVE + Cluster Size: 3 + Members: ID=127.0.0.1:13143 URL=amqp:tcp:192.168.1.101:6664,tcp:192.168.122.1:6664,tcp:10.16.10.62:6664 + : ID=127.0.0.1:13167 URL=amqp:tcp:192.168.1.101:6665,tcp:192.168.122.1:6665,tcp:10.16.10.62:6665 + : ID=127.0.0.1:13192 URL=amqp:tcp:192.168.1.101:6666,tcp:192.168.122.1:6666,tcp:10.16.10.62:6666 + + + The ID for each broker in cluster is given on the left. For instance, the ID for the first broker in the cluster is 127.0.0.1:13143. The URL in the output is the broker's advertized address. Let's use the ID to shut the broker down using the --stop command: + + + $ ./qpid-cluster localhost:6664 --stop 127.0.0.1:13143 + + +
+ +
+ Failover in Clients + + If a client is connected to a broker, the connection fails if the broker crashes or is killed. If heartbeat is enabled for the connection, a connection also fails if the broker hangs, the machine the broker is running on fails, or the network connection to the broker is lost — the connection fails no later than twice the heartbeat interval. + + + When a client's connection to a broker fails, any sent messages that have been acknowledged to the sender will have been replicated to all brokers in the cluster, any received messages that have not yet been acknowledged by the receiving client requeued to all brokers, and the client API notifies the application of the failure by throwing an exception. + + + Clients can be configured to automatically reconnect to another broker when it receives such an exception. Any messages that have been sent by the client, but not yet acknowledged as delivered, are resent. Any messages that have been read by the client, but not acknowledged, are delivered to the client. + + + TCP is slow to detect connection failures. A client can configure a connection to use a heartbeat to detect connection failure, and can specify a time interval for the heartbeat. If heartbeats are in use, failures will be detected no later than twice the heartbeat interval. The Java JMS client enables hearbeat by default. See the sections on Failover in Java JMS Clients and Failover in C++ Clients for the code to enable heartbeat. + +
+ Failover in Java JMS Clients + + In Java JMS clients, client failover is handled automatically if it is enabled in the connection. Any messages that have been sent by the client, but not yet acknowledged as delivered, are resent. Any messages that have been read by the client, but not acknowledged, are sent to the client. + + + You can configure a connection to use failover using the failover property: + + + + connectionfactory.qpidConnectionfactory = amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:5672'&failover='failover_exchange' + + + This property can take three values: + + + Failover Modes + + failover_exchange + + + If the connection fails, fail over to any other broker in the cluster. + + + + + + + roundrobin + + + If the connection fails, fail over to one of the brokers specified in the brokerlist. + + + + + + + singlebroker + + + Failover is not supported; the connection is to a single broker only. + + + + + + + + + In a Connection URL, heartbeat is set using the idle_timeout property, which is an integer corresponding to the heartbeat period in seconds. For instance, the following line from a JNDI properties file sets the heartbeat time out to 3 seconds: + + + + connectionfactory.qpidConnectionfactory = amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:5672',idle_timeout=3 + + +
+ +
+ Failover and the Qpid Messaging API + + The Qpid Messaging API also supports automatic reconnection in the event a connection fails. . Senders can also be configured to replay any in-doubt messages (i.e. messages whice were sent but not acknowleged by the broker. See "Connection Options" and "Sender Capacity and Replay" in Programming in Apache Qpid for details. + + + In C++ and python clients, heartbeats are disabled by default. You can enable them by specifying a heartbeat interval (in seconds) for the connection via the 'heartbeat' option. + + + See "Cluster Failover" in Programming in Apache Qpid for details on how to keep the client aware of cluster membership. + + +
+ + +
+ +
+ Error handling in Clusters + + If a broker crashes or is killed, or a broker machine failure, broker connection failure, or a broker hang is detected, the other brokers in the cluster are notified that it is no longer a member of the cluster. If a new broker is joined to the cluster, it synchronizes with an active broker to obtain the current cluster state; if this synchronization fails, the new broker exit the cluster and aborts. + + + If a broker becomes extremely busy and stops responding, it stops accepting incoming work. All other brokers continue processing, and the non-responsive node caches all AIS traffic. When it resumes, the broker completes processes all cached AIS events, then accepts further incoming work. + + + Broker hangs are only detected if the watchdog plugin is loaded and the --watchdog-interval option is set. The watchdog plug-in kills the qpidd broker process if it becomes stuck for longer than the watchdog interval. In some cases, e.g. certain phases of error resolution, it is possible for a stuck process to hang other cluster members that are waiting for it to send a message. Using the watchdog, the stuck process is terminated and removed from the cluster, allowing other members to continue and clients of the stuck process to fail over to other members. + + + Redundancy can also be achieved directly in the AIS network by specifying more than one network interface in the AIS configuration file. This causes Totem to use a redundant ring protocol, which makes failure of a single network transparent. + + + Redundancy can be achieved at the operating system level by using NIC bonding, which combines multiple network ports into a single group, effectively aggregating the bandwidth of multiple interfaces into a single connection. This provides both network load balancing and fault tolerance. + + + If any broker encounters an error, the brokers compare notes to see if they all received the same error. If not, the broker removes itself from the cluster and shuts itself down to ensure that all brokers in the cluster have consistent state. For instance, a broker may run out of disk space; if this happens, the broker shuts itself down. Examining the broker's log can help determine the error and suggest ways to prevent it from occuring in the future. + + +
+ +
+ Persistence in High Availability Message Clusters + + Persistence and clustering are two different ways to provide reliability. Most systems that use a cluster do not enable persistence, but you can do so if you want to ensure that messages are not lost even if the last broker in a cluster fails. A cluster must have all transient or all persistent members, mixed clusters are not allowed. Each broker in a persistent cluster has it's own independent replica of the cluster's state it its store. + +
+ Clean and Dirty Stores + + When a broker is an active member of a cluster, its store is marked "dirty" because it may be out of date compared to other brokers in the cluster. If a broker leaves a running cluster because it is stopped, it crashes or the host crashes, its store continues to be marked "dirty". + + + If the cluster is reduced to a single broker, its store is marked "clean" since it is the only broker making updates. If the cluster is shut down with the command qpid-cluster -k then all the stores are marked clean. + + + When a cluster is initially formed, brokers with clean stores read from their stores. Brokers with dirty stores, or brokers that join after the cluster is running, discard their old stores and initialize a new store with an update from one of the running brokers. The --truncate option can be used to force a broker to discard all existing stores even if they are clean. (A dirty store is discarded regardless.) + + + Discarded stores are copied to a back up directory. The active store is in <data-dir>/rhm. Back-up stores are in <data-dir>/_cluster.bak.<nnnn>/rhm, where <nnnn> is a 4 digit number. A higher number means a more recent backup. + + +
+ +
+ Starting a persistent cluster + + When starting a persistent cluster broker, set the cluster-size option to the number of brokers in the cluster. This allows the brokers to wait until the entire cluster is running so that they can synchronize their stored state. + + + The cluster can start if: + + + + + + all members have empty stores, or + + + + + + at least one member has a clean store + + + + + + + + + All members of the new cluster will be initialized with the state from a clean store. + + +
+ +
+ Stopping a persistent cluster + + To cleanly shut down a persistent cluster use the command qpid-cluster -k. This causes all brokers to synchronize their state and mark their stores as "clean" so they can be used when the cluster restarts. + + +
+ +
+ Starting a persistent cluster with no clean store + + If the cluster has previously had a total failure and there are no clean stores then the brokers will fail to start with the log message Cannot recover, no clean store. If this happens you can start the cluster by marking one of the stores "clean" as follows: + + + + + Move the latest store backup into place in the brokers data-directory. The backups end in a 4 digit number, the latest backup is the highest number. + + + + cd <data-dir> + mv rhm rhm.bak + cp -a _cluster.bak.<nnnn>/rhm . + + + + + + Mark the store as clean: + qpid-cluster-store -c <data-dir> + + + + + + + + + Now you can start the cluster, all members will be initialized from the store you marked as clean. + + +
+ +
+ Isolated failures in a persistent cluster + + A broker in a persistent cluster may encounter errors that other brokers in the cluster do not; if this happens, the broker shuts itself down to avoid making the cluster state inconsistent. For example a disk failure on one node will result in that node shutting down. Running out of storage capacity can also cause a node to shut down because because the brokers may not run out of storage at exactly the same point, even if they have similar storage configuration. To avoid unnecessary broker shutdowns, make sure the queue policy size of each durable queue is less than the capacity of the journal for the queue. + + +
+ + +
+ + +
diff --git a/qpid/doc/book/src/Active-Passive-Cluster.xml b/qpid/doc/book/src/Active-Passive-Cluster.xml new file mode 100644 index 0000000000..3eaadad51e --- /dev/null +++ b/qpid/doc/book/src/Active-Passive-Cluster.xml @@ -0,0 +1,361 @@ + + + +
+ + Active-passive Messaging Clusters (Preview) + +
+ Overview + + This release provides a preview of a new module for High Availability (HA). The new + module is not yet complete or ready for production use, it being made available so + that users can experiment with the new approach and provide feedback early in the + development process. Feedback should go to user@qpid.apache.org. + + + The old cluster module takes an active-active approach, + i.e. all the brokers in a cluster are able to handle client requests + simultaneously. The new HA module takes an active-passive, + hot-standby approach. + + + In an active-passive cluster, only one broker, known as the + primary, is active and serving clients at a time. The other + brokers are standing by as backups. Changes on the primary + are immediately replicated to all the backups so they are always up-to-date or + "hot". If the primary fails, one of the backups is promoted to be the new + primary. Clients fail-over to the new primary automatically. If there are multiple + backups, the backups also fail-over to become backups of the new primary. + + + The new approach depends on an external cluster resource + manager to detect failure of the primary and choose the new primary. The + first supported resource manager will be rgmanager, but it will + be possible to add integration with other resource managers in the future. The + preview version is not integrated with any resource manager, you can use the + qpid-ha tool to simulate the actions of a resource manager or do + your own integration. + +
+ Why the new approach? + The new active-passive approach has several advantages compared to the + existing active-active cluster module. + + + It does not depend directly on openais or corosync. It does not use multicast + which simplifies deployment. + + + It is more portable: in environments that don't support corosync, it can be + integrated with a resource manager available in that environment. + + + Replication to a disaster recovery site can be handled as + simply another node in the cluster, it does not require a separate replication + mechanism. + + + It can take advantage of features provided by the resource manager, for example + virtual IP addresses. + + + Improved performance and scalability due to better use of multiple CPU s + + +
+
+ + Limitations + + + There are a number of known limitations in the current preview implementation. These + will be fixed in the production versions. + + + + + Transactional changes to queue state are not replicated atomically. If the + primary crashes during a transaction, it is possible that the backup could + contain only part of the changes introduced by a transaction. + + + During a fail-over one backup is promoted to primary and any other backups switch to + the new primary. Messages sent to the new primary before all the backups have + switched could be lost if the new primary itself fails before all the backups have + switched. + + + When used with a persistent store: if the entire cluster fails, there are no tools + to help identify the most recent store. + + + Acknowledgments are confirmed to clients before the message has been dequeued + from replicas or indeed from the local store if that is asynchronous. + + + A persistent broker must have its store erased before joining an existing cluster. + In the production version a persistent broker will be able to load its store and + avoid downloading messages that are in the store from the primary. + + + Configuration changes (creating or deleting queues, exchanges and bindings) are + replicated asynchronously. Management tools used to make changes will consider the + change complete when it is complete on the primary, it may not yet be replicated + to all the backups. + + + Deletions made immediately after a failure (before all the backups are ready) may + be lost on a backup. Queues, exchange or bindings that were deleted on the primary could + re-appear if that backup is promoted to primary on a subsequent failure. + + + Better control is needed over which queues/exchanges are replicated and which are not. + + + There are some known issues affecting performance, both the throughput of + replication and the time taken for backups to fail-over. Performance will improve + in the production version. + + + Federated links from the primary will be lost in fail over, they will not be + re-connected on the new primary. Federation links to the primary can fail over. + + + Only plain FIFO queues can be replicated. LVQ and ring queues are not yet supported. + + +
+
+ + +
+ Configuring the Brokers + + The broker must load the ha module, it is loaded by default + when you start a broker. The following broker options are available for the HA module. + + + Options for High Availability Messaging Cluster + + + + + + + Options for High Availability Messaging Cluster + + + + + + + --ha-cluster yes|no + + + Set to "yes" to have the broker join a cluster. + + + + + --ha-brokers URL + + + URL use by brokers to connect to each other. The URL lists the addresses of + all the brokers in the cluster + + + If the resource manager supports virtual IP addresses then the URL can + contain just the single virtual IP. + + + in the following form: + + url = ["amqp:"][ user ["/" password] "@" ] addr ("," addr)* + addr = tcp_addr / rmda_addr / ssl_addr / ... + tcp_addr = ["tcp:"] host [":" port] + rdma_addr = "rdma:" host [":" port] + ssl_addr = "ssl:" host [":" port]' + + + + + --ha-public-brokers URL + + URL used by clients to connect to the brokers in the same format as + --ha-brokers above. Use this option if you want client + traffic on a different network from broker replication traffic. If this + option is not set, clients will use the same URL as brokers. + + + + + --ha-username USER + --ha-password PASS + --ha-mechanism MECH + + + Brokers use USER, + PASS, MECH to + authenticate when connecting to each other. + + + + +
+ + To configure a cluster you must set at least ha-cluster and ha-brokers + +
+ + +
+ Creating replicated queues and exchanges + + To create a replicated queue or exchange, pass the argument + qpid.replicate when creating the queue or exchange. It should + have one of the following three values: + + + all: Replicate the queue or exchange, messages and bindings. + + + configuration: Replicate the existence of the queue or + exchange and bindings but don't replicate messages. + + + none: Don't replicate, this is the default. + + + + Bindings are automatically replicated if the queue and exchange being bound both have + replication argument of all or confguration, they are + not replicated otherwise. + + You can create replicated queues and exchanges with the qpid-config + management tool like this: + + qpid-config add queue myqueue --replicate all + + + To create replicated queues and exchangs via the client API, add a node entry to the address like this: + + "myqueue;{create:always,node:{x-declare:{arguments:{'qpid.replicate':all}}}}" + +
+ + + +
+ Client Fail-over + + Clients can only connect to the single primary broker. All other brokers in the + cluster are backups, and they automatically reject any attempt by a client to + connect. + + + Clients are configured with the addreses of all of the brokers in the cluster. + + + If the resource manager supports virtual IP addresses then the clients + can be configured with a single virtual IP address. + + + When the client tries to connect initially, it will try all of its addresses until it + successfully connects to the primary. If the primary fails, clients will try to + try to re-connect to all the known brokers until they find the new primary. + + + Suppose your cluster has 3 nodes: node1, node2 and node3 all using the default AMQP port. + + + With the C++ client, you specify all the cluster addresses in a single URL, for example: + + qpid::messaging::Connection c("node1:node2:node3"); + + + + With the python client, you specify reconnect=True and a list of host:port addresses as reconnect_urls when calling establish or open + + connection = qpid.messaging.Connection.establish("node1", reconnect=True, "reconnect_urls=["node1", "node2", "node3"]) + + +
+ +
+ Broker fail-over + + Broker fail-over is managed by a cluster resource + manager. The initial preview version of HA is not integrated with a + resource manager, the production version will be integrated with rgmanager and it may + be integrated with other resource managers in the future. + + + The resource manager is responsible for ensuring that there is exactly one broker + is acting as primary at all times. It selects the initial primary broker when the + cluster is started, detects failure of the primary, and chooses the backup to + promote as the new primary. + + + You can simulate the actions of a resource manager, or indeed do your own + integration with a resource manager using the qpid-ha tool. The + command + + qpid-ha promote -b host:port + + will promote the broker listening on + host:port to be the primary. + You should only promote a broker to primary when there is no other primary in the + cluster. The brokers will not detect multiple primaries, they rely on the resource + manager to do that. + + + A clustered broker always starts initially in discovery + mode. It uses the addresses configured in the ha-brokers + configuration option and tries to connect to each in turn until it finds to the + primary. The resource manager is responsible for choosing on of the backups to + promote as the initial primary. + + + If the primary fails, all the backups are disconnected and return to discovery mode. + The resource manager chooses one to promote as the new primary. The other backups + will eventually discover the new primary and reconnect. + +
+
+ Broker Administration + + You can connect to a backup broker with the administrative tool + qpid-ha. You can also connect with the tools + qpid-config, qpid-route and + qpid-stat if you pass the flag --ha-admin on the + command line. If you do connect to a backup you should not modify any of the + replicated queues, as this will disrupt the replication and may result in + message loss. + +
+
+ diff --git a/qpid/doc/book/src/HA-Queue-Replication.xml b/qpid/doc/book/src/HA-Queue-Replication.xml new file mode 100644 index 0000000000..b7c533e4cb --- /dev/null +++ b/qpid/doc/book/src/HA-Queue-Replication.xml @@ -0,0 +1,54 @@ + + + +
+ Queue Replication with the HA module + + As well as support for an active-passive cluster, the ha module + also allows you to replicate individual queues. The original + queue is used as normal. The replica queue is updated + automatically as messages are added to or removed from the original queue. + + + To create a replica you need the HA module to be loaded on both the orignal and replica + brokers. Note that it is not safe to modify the replica queue other than via the + automatic updates from the original. Adding or removing messages on the replica queue + will make replication inconsistent and may cause message loss. The HA module does + not enforce restricted access to the replica queue (as it does in + the case of a cluster) so it is up to the application to ensure the replca is not used + until it has been disconnected from the original. + + + Suppose that myqueue is a queue on node1 and + we want to create a replica of myqueue on node2 + (where both brokers are using the default AMQP port.) This is accomplished by the command: + + qpid-config --broker=node2 add queue --start-replica node1 myqueue + + + + If myqueue already exists on the replica broker you can start replication from the original queue like this: + + qpid-ha replicate -b node2 node1 myqueue + + +
diff --git a/qpid/doc/book/src/Managing-CPP-Broker.xml b/qpid/doc/book/src/Managing-CPP-Broker.xml index 2cb4def764..d2abea4296 100644 --- a/qpid/doc/book/src/Managing-CPP-Broker.xml +++ b/qpid/doc/book/src/Managing-CPP-Broker.xml @@ -1,6 +1,6 @@
@@ -38,6 +38,8 @@ qpid-printevents - used to receive and print QMF events + qpid-ha - used to interact with the High Availability module +
@@ -119,10 +121,10 @@ Total Exchanges: 6 $ qpid-config queues Queue Name Attributes ================================================================= -pub_start -pub_done -sub_ready -sub_done +pub_start +pub_done +sub_ready +sub_done perftest0 --durable reply-dhcp-100-18-254.bos.redhat.com.20713 auto-del excl topic-dhcp-100-18-254.bos.redhat.com.20713 auto-del excl @@ -459,4 +461,25 @@ Options: You get the idea... have fun! </para> <!--h3--></section> +<section> + <title>Using qpid-ha + This utility lets you monitor and control the activity of the clustering behavior provided by the HA module. + + + [] + +Commands are: + + ready Test if a backup broker is ready. + query Print HA configuration settings. + set Set HA configuration settings. + promote Promote broker from backup to primary. + replicate Set up replication from on to on the current broker. + +For help with a command type: qpid-ha --help +]]> + +
diff --git a/qpid/doc/book/src/Programming-In-Apache-Qpid.xml b/qpid/doc/book/src/Programming-In-Apache-Qpid.xml index adcac6aab3..3052e2acc1 100644 --- a/qpid/doc/book/src/Programming-In-Apache-Qpid.xml +++ b/qpid/doc/book/src/Programming-In-Apache-Qpid.xml @@ -3,24 +3,24 @@ +--> Programming in Apache Qpid @@ -30,8 +30,8 @@ Introduction Apache Qpid is a reliable, asynchronous messaging system that - supports the AMQP messaging protocol in several common programming - languages. Qpid is supported on most common platforms. + supports the AMQP messaging protocol in several common programming + languages. Qpid is supported on most common platforms. @@ -67,7 +67,7 @@ Using the Qpid Messaging API The Qpid Messaging API is quite simple, consisting of only a - handful of core classes. + handful of core classes. @@ -126,29 +126,29 @@ A Simple Messaging Program in C++ The following C++ program shows how to create a connection, - create a session, send messages using a sender, and receive - messages using a receiver. + create a session, send messages using a sender, and receive + messages using a receiver. - - "Hello world!" in C++ - -#include -#include -#include -#include + + "Hello world!" in C++ + + #include + #include + #include + #include -#include ]]> + #include ]]> -using namespace qpid::messaging; + using namespace qpid::messaging; -int main(int argc, char** argv) { - std::string broker = argc > 1 ? argv[1] : "localhost:5672"; - std::string address = argc > 2 ? argv[2] : "amq.topic"; - std::string connectionOptions = argc > 3 ? argv[3] : ""; + int main(int argc, char** argv) { + std::string broker = argc > 1 ? argv[1] : "localhost:5672"; + std::string address = argc > 2 ? argv[2] : "amq.topic"; + std::string connectionOptions = argc > 3 ? argv[3] : ""; - Connection connection(broker, connectionOptions); - try { + Connection connection(broker, connectionOptions); + try { connection.open(); Session session = connection.createSession(); @@ -163,38 +163,38 @@ int main(int argc, char** argv) { connection.close(); return 0; - } catch(const std::exception& error) { + } catch(const std::exception& error) { connection.close(); return 1; - } -} - - - - Establishes the connection with the messaging broker. - - - Creates a session object on which messages will be sent and received. - - - Creates a receiver that receives messages from the given address. - - - Creates a sender that sends to the given address. - - - Receives the next message. The duration is optional, if omitted, will wait indefinitely for the next message. - - - Acknowledges receipt of all fetched messages on the - session. This informs the broker that the messages were - transferred and processed by the client successfully. - - - Closes the connection, all sessions managed by the connection, and all senders and receivers managed by each session. - - + } + } + + + + Establishes the connection with the messaging broker. + + + Creates a session object on which messages will be sent and received. + + + Creates a receiver that receives messages from the given address. + + + Creates a sender that sends to the given address. + + + Receives the next message. The duration is optional, if omitted, will wait indefinitely for the next message. + + + Acknowledges receipt of all fetched messages on the + session. This informs the broker that the messages were + transferred and processed by the client successfully. + + + Closes the connection, all sessions managed by the connection, and all senders and receivers managed by each session. + + @@ -204,66 +204,66 @@ int main(int argc, char** argv) { A Simple Messaging Program in Python The following Python program shows how to create a - connection, create a session, send messages using a sender, and - receive messages using a receiver. + connection, create a session, send messages using a sender, and + receive messages using a receiver. - - "Hello world!" in Python - - -connection = Connection(broker) - -try: - connection.open() - session = connection.session() - - sender = session.sender(address) - receiver = session.receiver(address) - - sender.send(Message("Hello world!")); - - message = receiver.fetch(timeout=1) - print message.content - session.acknowledge() - -except MessagingError,m: - print m -finally: - connection.close() - - - - - Establishes the connection with the messaging broker. - - - Creates a session object on which messages will be sent and received. - - - Creates a receiver that receives messages from the given address. - - - Creates a sender that sends to the given address. - - - Receives the next message. The duration is optional, if omitted, will wait indefinitely for the next message. - - - Acknowledges receipt of all fetched messages on - the session. This informs the broker that the messages were - transfered and processed by the client successfully. - - - Closes the connection, all sessions managed by the connection, and all senders and receivers managed by each session. - - + + "Hello world!" in Python + + broker = "localhost:5672" if len(sys.argv)<2 else sys.argv[1] + address = "amq.topic" if len(sys.argv)<3 else sys.argv[2]]]> + + connection = Connection(broker) + + try: + connection.open() + session = connection.session() + + sender = session.sender(address) + receiver = session.receiver(address) + + sender.send(Message("Hello world!")); + + message = receiver.fetch(timeout=1) + print message.content + session.acknowledge() + + except MessagingError,m: + print m + finally: + connection.close() + + + + + Establishes the connection with the messaging broker. + + + Creates a session object on which messages will be sent and received. + + + Creates a receiver that receives messages from the given address. + + + Creates a sender that sends to the given address. + + + Receives the next message. The duration is optional, if omitted, will wait indefinitely for the next message. + + + Acknowledges receipt of all fetched messages on + the session. This informs the broker that the messages were + transfered and processed by the client successfully. + + + Closes the connection, all sessions managed by the connection, and all senders and receivers managed by each session. + + + + @@ -274,86 +274,86 @@ finally: A Simple Messaging Program in .NET C# The following .NET C# - - - The .NET binding for the Qpid C++ Messaging API - applies to all .NET Framework managed code languages. C# was chosen - for illustration purposes only. - - - program shows how to create a connection, - create a session, send messages using a sender, and receive - messages using a receiver. + + + The .NET binding for the Qpid C++ Messaging API + applies to all .NET Framework managed code languages. C# was chosen + for illustration purposes only. + + + program shows how to create a connection, + create a session, send messages using a sender, and receive + messages using a receiver. - - "Hello world!" in .NET C# - -using System; -using Org.Apache.Qpid.Messaging; - -namespace Org.Apache.Qpid.Messaging { - class Program { - static void Main(string[] args) { - String broker = args.Length > 0 ? args[0] : "localhost:5672"; - String address = args.Length > 1 ? args[1] : "amq.topic"; - - Connection connection = null; - try { - connection = new Connection(broker); - connection.Open(); - Session session = connection.CreateSession(); - - Receiver receiver = session.CreateReceiver(address); - Sender sender = session.CreateSender(address); - - sender.Send(new Message("Hello world!")); - - Message message = new Message(); - message = receiver.Fetch(DurationConstants.SECOND * 1); - Console.WriteLine("{0}", message.GetContent()); - session.Acknowledge(); - - connection.Close(); - } catch (Exception e) { - Console.WriteLine("Exception {0}.", e); - if (null != connection) - connection.Close(); - } - } - } -} + + "Hello world!" in .NET C# + + using System; + using Org.Apache.Qpid.Messaging; + + namespace Org.Apache.Qpid.Messaging { + class Program { + static void Main(string[] args) { + String broker = args.Length > 0 ? args[0] : "localhost:5672"; + String address = args.Length > 1 ? args[1] : "amq.topic"; + + Connection connection = null; + try { + connection = new Connection(broker); + connection.Open(); + Session session = connection.CreateSession(); + + Receiver receiver = session.CreateReceiver(address); + Sender sender = session.CreateSender(address); + + sender.Send(new Message("Hello world!")); + + Message message = new Message(); + message = receiver.Fetch(DurationConstants.SECOND * 1); + Console.WriteLine("{0}", message.GetContent()); + session.Acknowledge(); + + connection.Close(); + } catch (Exception e) { + Console.WriteLine("Exception {0}.", e); + if (null != connection) + connection.Close(); + } + } + } + } - + - - - Permits use of Org.Apache.Qpid.Messaging types and methods without explicit namespace qualification. Any .NET project must have a project reference to the assembly file Org.Apache.Qpid.Messaging.dll in order to obtain the definitions of the .NET Binding for Qpid Messaging namespace. - - - Establishes the connection with the messaging broker. - - - Creates a session object on which messages will be sent and received. - - - Creates a receiver that receives messages from the given address. - - - Creates a sender that sends to the given address. - - - Receives the next message. The duration is optional, if omitted, will wait indefinitely for the next message. - - - Acknowledges receipt of all fetched messages on the - session. This informs the broker that the messages were - transfered and processed by the client successfully. - - - Closes the connection, all sessions managed by the connection, and all senders and receivers managed by each session. - - + + + Permits use of Org.Apache.Qpid.Messaging types and methods without explicit namespace qualification. Any .NET project must have a project reference to the assembly file Org.Apache.Qpid.Messaging.dll in order to obtain the definitions of the .NET Binding for Qpid Messaging namespace. + + + Establishes the connection with the messaging broker. + + + Creates a session object on which messages will be sent and received. + + + Creates a receiver that receives messages from the given address. + + + Creates a sender that sends to the given address. + + + Receives the next message. The duration is optional, if omitted, will wait indefinitely for the next message. + + + Acknowledges receipt of all fetched messages on the + session. This informs the broker that the messages were + transfered and processed by the client successfully. + + + Closes the connection, all sessions managed by the connection, and all senders and receivers managed by each session. + + @@ -386,43 +386,43 @@ namespace Org.Apache.Qpid.Messaging { Qpid Messaging API recognises two kinds of nodes, queues and topics - The terms queue and - topic here were chosen to align with - their meaning in JMS. These two addressing 'patterns', - queue and topic, are sometimes refered as point-to-point - and publish-subscribe. AMQP 0-10 has an exchange type - called a topic exchange. When the term - topic occurs alone, it refers to a - Messaging API topic, not the topic - exchange.. + The terms queue and + topic here were chosen to align with + their meaning in JMS. These two addressing 'patterns', + queue and topic, are sometimes refered as point-to-point + and publish-subscribe. AMQP 0-10 has an exchange type + called a topic exchange. When the term + topic occurs alone, it refers to a + Messaging API topic, not the topic + exchange.. A queue stores each message until it has been received and acknowledged, and only one receiver can receive a given message - There are exceptions to this rule; for instance, - a receiver can use browse mode, which leaves - messages on the queue for other receivers to - read.. + There are exceptions to this rule; for instance, + a receiver can use browse mode, which leaves + messages on the queue for other receivers to + read.. A topic immediately delivers a message to all eligible receivers; if there are no eligible receivers, it discards the message. In the AMQP 0-10 implementation of the API, - The AMQP 0-10 implementation is the only one - that currently exists. + The AMQP 0-10 implementation is the only one + that currently exists. queues map to AMQP queues, and topics map to AMQP exchanges. - In AMQP 0-10, messages are sent to - exchanges, and read from queues. The Messaging API also - allows a sender to send messages to a queue; internally, - Qpid implements this by sending the message to the default - exchange, with the name of the queue as the routing key. The - Messaging API also allows a receiver to receive messages - from a topic; internally, Qpid implements this by setting up - a private subscription queue for the receiver and binding - the subscription queue to the exchange that corresponds to - the topic. + In AMQP 0-10, messages are sent to + exchanges, and read from queues. The Messaging API also + allows a sender to send messages to a queue; internally, + Qpid implements this by sending the message to the default + exchange, with the name of the queue as the routing key. The + Messaging API also allows a receiver to receive messages + from a topic; internally, Qpid implements this by setting up + a private subscription queue for the receiver and binding + the subscription queue to the exchange that corresponds to + the topic. In the rest of this tutorial, we present many examples @@ -430,7 +430,7 @@ namespace Org.Apache.Qpid.Messaging { parameter. spout sends messages to the target address, drain receives messages from the source address. The source code is available in C++, Python, and - .NET C# and can be found in the examples directory for each + .NET C# and can be found in the examples directory for each language. These programs can use any address string as a source or a destination, and have many command line options to configure behavior—use the -h option @@ -454,14 +454,14 @@ namespace Org.Apache.Qpid.Messaging { Queues Create a queue with qpid-config, send a message using - spout, and read it using drain: + spout, and read it using drain: -$ qpid-config add queue hello-world -$ ./spout hello-world -$ ./drain hello-world + $ qpid-config add queue hello-world + $ ./spout hello-world + $ ./drain hello-world -Message(properties={spout-id:c877e622-d57b-4df2-bf3e-6014c68da0ea:0}, content='') + Message(properties={spout-id:c877e622-d57b-4df2-bf3e-6014c68da0ea:0}, content='') The queue stored the message sent by spout and delivered @@ -472,8 +472,8 @@ Message(properties={spout-id:c877e622-d57b-4df2-bf3e-6014c68da0ea:0}, content='' drain one more time, no messages will be retrieved. -$ ./drain hello-world -$ + $ ./drain hello-world + $ @@ -488,16 +488,16 @@ $ and create an exchange with the same name: -$ qpid-config del queue hello-world -$ qpid-config add exchange topic hello-world + $ qpid-config del queue hello-world + $ qpid-config add exchange topic hello-world Now run drain and spout the same way we did in the previous example: -$ ./spout hello-world -$ ./drain hello-world -$ + $ ./spout hello-world + $ ./drain hello-world + $ Topics deliver messages immediately to any interested @@ -515,27 +515,27 @@ $ First Window: -$ ./drain -t 30 hello-word + $ ./drain -t 30 hello-word Second Window: -$ ./spout hello-word + $ ./spout hello-word Once spout has sent a message, return - to the first window to see the output from - drain: + to the first window to see the output from + drain: -Message(properties={spout-id:7da2d27d-93e6-4803-8a61-536d87b8d93f:0}, content='') + Message(properties={spout-id:7da2d27d-93e6-4803-8a61-536d87b8d93f:0}, content='') You can run drain in several separate - windows; each creates a subscription for the exchange, and - each receives all messages sent to the exchange. + windows; each creates a subscription for the exchange, and + each receives all messages sent to the exchange. @@ -551,9 +551,9 @@ Message(properties={spout-id:7da2d27d-93e6-4803-8a61-536d87b8d93f:0}, content='' The syntax for an address string is: [ / ] [ ; ] -options ::= { : , ... } -]]> + address_string ::=
[ / ] [ ; ] + options ::= { : , ... } + ]]> Addresses, subjects, and keys are strings. Values can be numbers, strings (with optional single or double quotes), @@ -582,62 +582,62 @@ options ::= { : , ... } If a receiver's address contains a subject, it is used to select only messages that match the subject—the matching algorithm depends on the message source. - - - - In AMQP 0-10, each exchange type has its own matching - algorithm. This is discussed in - . - + - - Currently, a receiver bound to a queue ignores subjects, - receiving messages from the queue without filtering. Support - for subject filtering on queues will be implemented soon. + In AMQP 0-10, each exchange type has its own matching + algorithm. This is discussed in + . - + + + Currently, a receiver bound to a queue ignores subjects, + receiving messages from the queue without filtering. Support + for subject filtering on queues will be implemented soon. + + - - Using subjects - In this example we show how subjects affect message - flow. + + Using subjects - First, let's use qpid-config to create a topic exchange. + In this example we show how subjects affect message + flow. - -$ qpid-config add exchange topic news-service - + First, let's use qpid-config to create a topic exchange. - Now we use drain to receive messages from news-service that match the subject sports. - First Window: - -$ ./drain -t 30 news-service/sports - + + $ qpid-config add exchange topic news-service + - In a second window, let's send messages to news-service using two different subjects: + Now we use drain to receive messages from news-service that match the subject sports. + First Window: + + $ ./drain -t 30 news-service/sports + - Second Window: - -$ ./spout news-service/sports -$ ./spout news-service/news - + In a second window, let's send messages to news-service using two different subjects: - Now look at the first window, the message with the - subject sports has been received, but not - the message with the subject news: + Second Window: + + $ ./spout news-service/sports + $ ./spout news-service/news + - -Message(properties={qpid.subject:sports, spout-id:9441674e-a157-4780-a78e-f7ccea998291:0}, content='') - + Now look at the first window, the message with the + subject sports has been received, but not + the message with the subject news: + + + Message(properties={qpid.subject:sports, spout-id:9441674e-a157-4780-a78e-f7ccea998291:0}, content='') + - If you run drain in multiple + If you run drain in multiple windows using the same subject, all instances of drain receive the messages for that subject. - + The AMQP exchange type we are using here, @@ -663,855 +663,855 @@ Message(properties={qpid.subject:sports, spout-id:9441674e-a157-4780-a78e-f7ccea like europe.news or europe.pseudo.news. - - Subjects with multi-word keys + + Subjects with multi-word keys - This example uses drain and spout to demonstrate the - use of subjects with two-word keys. + This example uses drain and spout to demonstrate the + use of subjects with two-word keys. - Let's use drain with the subject - *.news to listen for messages in which - the second word of the key is - news. + Let's use drain with the subject + *.news to listen for messages in which + the second word of the key is + news. - First Window: + First Window: - -$ ./drain -t 30 news-service/*.news - + + $ ./drain -t 30 news-service/*.news + - Now let's send messages using several different - two-word keys: + Now let's send messages using several different + two-word keys: - Second Window: + Second Window: - -$ ./spout news-service/usa.news -$ ./spout news-service/usa.sports -$ ./spout news-service/europe.sports -$ ./spout news-service/europe.news - + + $ ./spout news-service/usa.news + $ ./spout news-service/usa.sports + $ ./spout news-service/europe.sports + $ ./spout news-service/europe.news + - In the first window, the messages with - news in the second word of the key have - been received: + In the first window, the messages with + news in the second word of the key have + been received: - -Message(properties={qpid.subject:usa.news, spout-id:73fc8058-5af6-407c-9166-b49a9076097a:0}, content='') -Message(properties={qpid.subject:europe.news, spout-id:f72815aa-7be4-4944-99fd-c64c9747a876:0}, content='') - + + Message(properties={qpid.subject:usa.news, spout-id:73fc8058-5af6-407c-9166-b49a9076097a:0}, content='') + Message(properties={qpid.subject:europe.news, spout-id:f72815aa-7be4-4944-99fd-c64c9747a876:0}, content='') + - Next, let's use drain with the - subject #.news to match any sequence of - words that ends with news. + Next, let's use drain with the + subject #.news to match any sequence of + words that ends with news. - First Window: + First Window: - -$ ./drain -t 30 news-service/#.news - + + $ ./drain -t 30 news-service/#.news + - In the second window, let's send messages using a - variety of different multi-word keys: + In the second window, let's send messages using a + variety of different multi-word keys: - Second Window: + Second Window: - -$ ./spout news-service/news -$ ./spout news-service/sports -$ ./spout news-service/usa.news -$ ./spout news-service/usa.sports -$ ./spout news-service/usa.faux.news -$ ./spout news-service/usa.faux.sports - + + $ ./spout news-service/news + $ ./spout news-service/sports + $ ./spout news-service/usa.news + $ ./spout news-service/usa.sports + $ ./spout news-service/usa.faux.news + $ ./spout news-service/usa.faux.sports + - In the first window, messages with - news in the last word of the key have been - received: + In the first window, messages with + news in the last word of the key have been + received: - -Message(properties={qpid.subject:news, spout-id:cbd42b0f-c87b-4088-8206-26d7627c9640:0}, content='') -Message(properties={qpid.subject:usa.news, spout-id:234a78d7-daeb-4826-90e1-1c6540781eac:0}, content='') -Message(properties={qpid.subject:usa.faux.news, spout-id:6029430a-cfcb-4700-8e9b-cbe4a81fca5f:0}, content='') - - + + Message(properties={qpid.subject:news, spout-id:cbd42b0f-c87b-4088-8206-26d7627c9640:0}, content='') + Message(properties={qpid.subject:usa.news, spout-id:234a78d7-daeb-4826-90e1-1c6540781eac:0}, content='') + Message(properties={qpid.subject:usa.faux.news, spout-id:6029430a-cfcb-4700-8e9b-cbe4a81fca5f:0}, content='') + + - + -
- Address String Options +
+ Address String Options - - The options in an address string can contain additional - information for the senders or receivers created for it, - including: - - - - - Policies for assertions about the node to which an address - refers. - - - For instance, in the address string my-queue; - {assert: always, node:{ type: queue }}, the node - named my-queue must be a queue; if not, - the address does not resolve to a node, and an exception - is raised. - - - - - Policies for automatically creating or deleting the node to which an address refers. - - - For instance, in the address string xoxox ; {create: always}, - the queue xoxox is created, if it does - not exist, before the address is resolved. - - - - - Extension points that can be used for sender/receiver configuration. - + + The options in an address string can contain additional + information for the senders or receivers created for it, + including: + + + + + Policies for assertions about the node to which an address + refers. + + + For instance, in the address string my-queue; + {assert: always, node:{ type: queue }}, the node + named my-queue must be a queue; if not, + the address does not resolve to a node, and an exception + is raised. + + + + + Policies for automatically creating or deleting the node to which an address refers. + + + For instance, in the address string xoxox ; {create: always}, + the queue xoxox is created, if it does + not exist, before the address is resolved. + + + + + Extension points that can be used for sender/receiver configuration. + + + For instance, if the address for a receiver is + my-queue; {mode: browse}, the receiver + works in browse mode, leaving messages + on the queue so other receivers can receive them. + + + + + Extension points providing more direct control over the underlying protocol. + + + For instance, the x-bindings property + allows greater control over the AMQP 0-10 binding process + when an address is resolved. + + + + + + + Let's use some examples to show how these different kinds of + address string options affect the behavior of senders and + receives. + + +
+ assert - For instance, if the address for a receiver is - my-queue; {mode: browse}, the receiver - works in browse mode, leaving messages - on the queue so other receivers can receive them. - - - - - Extension points providing more direct control over the underlying protocol. + In this section, we use the assert option + to ensure that the address resolves to a node of the required + type. - - For instance, the x-bindings property - allows greater control over the AMQP 0-10 binding process - when an address is resolved. - - - - - Let's use some examples to show how these different kinds of - address string options affect the behavior of senders and - receives. - - -
- assert - - In this section, we use the assert option - to ensure that the address resolves to a node of the required - type. - + + Assertions on Nodes + Let's use qpid-config to create a + queue and a topic. - - Assertions on Nodes + + $ qpid-config add queue my-queue + $ qpid-config add exchange topic my-topic + - Let's use qpid-config to create a - queue and a topic. + + We can now use the address specified to drain to assert that it is + of a particular type: + - -$ qpid-config add queue my-queue -$ qpid-config add exchange topic my-topic - + + $ ./drain 'my-queue; {assert: always, node:{ type: queue }}' + $ ./drain 'my-queue; {assert: always, node:{ type: topic }}' + 2010-04-20 17:30:46 warning Exception received from broker: not-found: not-found: Exchange not found: my-queue (../../src/qpid/broker/ExchangeRegistry.cpp:92) [caused by 2 \x07:\x01] + Exchange my-queue does not exist + - - We can now use the address specified to drain to assert that it is - of a particular type: - + + The first attempt passed without error as my-queue is indeed a + queue. The second attempt however failed; my-queue is not a + topic. + - -$ ./drain 'my-queue; {assert: always, node:{ type: queue }}' -$ ./drain 'my-queue; {assert: always, node:{ type: topic }}' -2010-04-20 17:30:46 warning Exception received from broker: not-found: not-found: Exchange not found: my-queue (../../src/qpid/broker/ExchangeRegistry.cpp:92) [caused by 2 \x07:\x01] -Exchange my-queue does not exist - + + We can do the same thing for my-topic: + - - The first attempt passed without error as my-queue is indeed a - queue. The second attempt however failed; my-queue is not a - topic. - + + $ ./drain 'my-topic; {assert: always, node:{ type: topic }}' + $ ./drain 'my-topic; {assert: always, node:{ type: queue }}' + 2010-04-20 17:31:01 warning Exception received from broker: not-found: not-found: Queue not found: my-topic (../../src/qpid/broker/SessionAdapter.cpp:754) [caused by 1 \x08:\x01] + Queue my-topic does not exist + + - - We can do the same thing for my-topic: - + Now let's use the create option to + create the queue xoxox if it does not already + exist: - -$ ./drain 'my-topic; {assert: always, node:{ type: topic }}' -$ ./drain 'my-topic; {assert: always, node:{ type: queue }}' -2010-04-20 17:31:01 warning Exception received from broker: not-found: not-found: Queue not found: my-topic (../../src/qpid/broker/SessionAdapter.cpp:754) [caused by 1 \x08:\x01] -Queue my-topic does not exist - - +
- Now let's use the create option to - create the queue xoxox if it does not already - exist: +
+ create -
+ In previous examples, we created the queue before + listening for messages on it. Using create: + always, the queue is automatically created if it + does not exist. -
- create + + Creating a Queue Automatically - In previous examples, we created the queue before - listening for messages on it. Using create: - always, the queue is automatically created if it - does not exist. + First Window: + $ ./drain -t 30 "xoxox ; {create: always}" - - Creating a Queue Automatically - First Window: - $ ./drain -t 30 "xoxox ; {create: always}" + Now we can send messages to this queue: + Second Window: + $ ./spout "xoxox ; {create: always}" - Now we can send messages to this queue: + Returning to the first window, we see that drain has received this message: - Second Window: - $ ./spout "xoxox ; {create: always}" + Message(properties={spout-id:1a1a3842-1a8b-4f88-8940-b4096e615a7d:0}, content='') + + The details of the node thus created can be controlled by further options within the node. See for details. +
- Returning to the first window, we see that drain has received this message: +
+ browse + Some options specify message transfer semantics; for + instance, they may state whether messages should be consumed or + read in browsing mode, or specify reliability + characteristics. The following example uses the + browse option to receive messages without + removing them from a queue. - Message(properties={spout-id:1a1a3842-1a8b-4f88-8940-b4096e615a7d:0}, content='') - - The details of the node thus created can be controlled by further options within the node. See for details. -
+ + Browsing a Queue + + Let's use the browse mode to receive messages without + removing them from the queue. First we send three messages to the + queue: + + + $ ./spout my-queue --content one + $ ./spout my-queue --content two + $ ./spout my-queue --content three + -
- browse - Some options specify message transfer semantics; for - instance, they may state whether messages should be consumed or - read in browsing mode, or specify reliability - characteristics. The following example uses the - browse option to receive messages without - removing them from a queue. + Now we use drain to get those messages, using the browse option: + + $ ./drain 'my-queue; {mode: browse}' + Message(properties={spout-id:fbb93f30-0e82-4b6d-8c1d-be60eb132530:0}, content='one') + Message(properties={spout-id:ab9e7c31-19b0-4455-8976-34abe83edc5f:0}, content='two') + Message(properties={spout-id:ea75d64d-ea37-47f9-96a9-d38e01c97925:0}, content='three') + - - Browsing a Queue - - Let's use the browse mode to receive messages without - removing them from the queue. First we send three messages to the - queue: - - -$ ./spout my-queue --content one -$ ./spout my-queue --content two -$ ./spout my-queue --content three - + We can confirm the messages are still on the queue by repeating the drain: + + $ ./drain 'my-queue; {mode: browse}' + Message(properties={spout-id:fbb93f30-0e82-4b6d-8c1d-be60eb132530:0}, content='one') + Message(properties={spout-id:ab9e7c31-19b0-4455-8976-34abe83edc5f:0}, content='two') + Message(properties={spout-id:ea75d64d-ea37-47f9-96a9-d38e01c97925:0}, content='three') + + +
- Now we use drain to get those messages, using the browse option: - -$ ./drain 'my-queue; {mode: browse}' -Message(properties={spout-id:fbb93f30-0e82-4b6d-8c1d-be60eb132530:0}, content='one') -Message(properties={spout-id:ab9e7c31-19b0-4455-8976-34abe83edc5f:0}, content='two') -Message(properties={spout-id:ea75d64d-ea37-47f9-96a9-d38e01c97925:0}, content='three') - +
+ x-bindings + + Greater control over the AMQP 0-10 binding process can + be achieved by including an x-bindings + option in an address string. + + For instance, the XML Exchange is an AMQP 0-10 custom exchange + provided by the Apache Qpid C++ broker. It allows messages to + be filtered using XQuery; queries can address either message + properties or XML content in the body of the message. The + xquery is specified in the arguments field of the AMQP 0-10 + command. When using the messaging API an xquery can be + specified in and address that resolves to an XML exchange by + using the x-bindings property. + + + An instance of the XML Exchange must be added before it + can be used: + + + $ qpid-config add exchange xml xml + + + When using the XML Exchange, a receiver provides an + XQuery as an x-binding argument. If the query contains a + context item (a path starting with .), then it + is applied to the content of the message, which must be + well-formed XML. For instance, ./weather is + a valid XQuery, which matches any message in which the root + element is named weather. Here is an + address string that contains this query: - We can confirm the messages are still on the queue by repeating the drain: - -$ ./drain 'my-queue; {mode: browse}' -Message(properties={spout-id:fbb93f30-0e82-4b6d-8c1d-be60eb132530:0}, content='one') -Message(properties={spout-id:ab9e7c31-19b0-4455-8976-34abe83edc5f:0}, content='two') -Message(properties={spout-id:ea75d64d-ea37-47f9-96a9-d38e01c97925:0}, content='three') - - -
+ + + When using longer queries with drain, + it is often useful to place the query in a file, and use + cat in the command line. We do this in the + following example. -
- x-bindings + + Using the XML Exchange - Greater control over the AMQP 0-10 binding process can - be achieved by including an x-bindings - option in an address string. + This example uses an x-binding that contains queries, which filter based on the content of XML messages. Here is an XQuery that we will use in this example: - For instance, the XML Exchange is an AMQP 0-10 custom exchange - provided by the Apache Qpid C++ broker. It allows messages to - be filtered using XQuery; queries can address either message - properties or XML content in the body of the message. The - xquery is specified in the arguments field of the AMQP 0-10 - command. When using the messaging API an xquery can be - specified in and address that resolves to an XML exchange by - using the x-bindings property. + + 50 + and $w/temperature_f - $w/dewpoint > 5 + and $w/wind_speed_mph > 7 + and $w/wind_speed_mph < 20 ]]> + + We can specify this query in an x-binding to listen to messages that meet the criteria specified by the query: - An instance of the XML Exchange must be added before it - can be used: + First Window: - -$ qpid-config add exchange xml xml - + + $ ./drain -f "xml; {link:{x-bindings:[{key:'weather', + arguments:{xquery:\"$(cat rdu.xquery )\"}}]}}" + - When using the XML Exchange, a receiver provides an - XQuery as an x-binding argument. If the query contains a - context item (a path starting with .), then it - is applied to the content of the message, which must be - well-formed XML. For instance, ./weather is - a valid XQuery, which matches any message in which the root - element is named weather. Here is an - address string that contains this query: + In another window, let's create an XML message that meets the criteria in the query, and place it in the file rdu.xml: + + + + Raleigh-Durham International Airport (KRDU) + 16 + 70 + 35 + + ]]> + + Now let's use spout to send this message to the XML exchange: + + Second Window: + + spout --content "$(cat rdu.xml)" xml/weather + + + Returning to the first window, we see that the message has been received: + + + Raleigh-Durham International Airport (KRDU) + 16 + 40 + 35 + ') ]]> + + +
- + - - Using the XML Exchange + - This example uses an x-binding that contains queries, which filter based on the content of XML messages. Here is an XQuery that we will use in this example: +
+ Address String Options - Reference + + + Address String Options + + + + + + + option + value + semantics + + + + + + assert + + + one of: always, never, sender or receiver + + + Asserts that the properties specified in the node option + match whatever the address resolves to. If they do not, + resolution fails and an exception is raised. + + + + + + create + + + one of: always, never, sender or receiver + + + Creates the node to which an address refers if it does + not exist. No error is raised if the node does + exist. The details of the node may be specified in the + node option. + + + + + delete + + + one of: always, never, sender or receiver + + + Delete the node when the sender or receiver is closed. + + + + + node + + + A nested map containing the entries shown in . + + + Specifies properties of the node to which the address + refers. These are used in conjunction with the assert or + create options. + + + + + link + + + A nested map containing the entries shown in . + + + Used to control the establishment of a conceptual link + from the client application to or from the target/source + address. + + + + + mode + + + one of: browse, consume + + + This option is only of relevance for source addresses + that resolve to a queue. If browse is specified the + messages delivered to the receiver are left on the queue + rather than being removed. If consume is specified the + normal behaviour applies; messages are removed from the + queue once the client acknowledges their receipt. + + + + +
+ + + + Node Properties + + + + + + + property + value + semantics + + + + + + type + + + topic, queue + + + Indicates the type of the node. + + + + + durable + + + True, False + + + Indicates whether the node survives a loss of + volatile storage e.g. if the broker is restarted. + + + + + x-declare + + + A nested map whose values correspond to the valid fields + on an AMQP 0-10 queue-declare or exchange-declare + command. + + + These values are used to fine tune the creation or + assertion process. Note however that they are protocol + specific. + + + + + x-bindings + + + A nested list in which each binding is represented by + a map. The entries of the map for a binding contain + the fields that describe an AMQP 0-10 binding. Here is + the format for x-bindings: + + , + queue: , + key: , + arguments: { + : , + ..., + : } + }, + ... + ] + ]]> + + + In conjunction with the create option, each of these + bindings is established as the address is resolved. In + conjunction with the assert option, the existence of + each of these bindings is verified during + resolution. Again, these are protocol specific. + + + + +
+ + + Link Properties + + + + + + + option + value + semantics + + + + + + reliability + + + one of: unreliable, at-least-once, at-most-once, exactly-once + + + Reliability indicates the level of reliability that + the sender or receiver. unreliable + and at-most-once are currently + treated as synonyms, and allow messages to be lost if + a broker crashes or the connection to a broker is + lost. at-least-once guarantees that + a message is not lost, but duplicates may be + received. exactly-once guarantees + that a message is not lost, and is delivered precisely + once. Currently only unreliable + and at-least-once are supported. + If at-most-once is requested, + unreliable will be used and for durable messages on + durable queues there is the possibility that messages + will be redelivered; if exactly-once is requested, + at-most-once will be used and the application needs to + be able to deal with duplicates. + + + + + durable + + + True, False + + + Indicates whether the link survives a loss of + volatile storage e.g. if the broker is restarted. + + + + + x-declare + + + A nested map whose values correspond to the valid fields + of an AMQP 0-10 queue-declare command. + + + These values can be used to customise the subscription + queue in the case of receiving from an exchange. Note + however that they are protocol specific. + + + + + x-subscribe + + + A nested map whose values correspond to the valid fields + of an AMQP 0-10 message-subscribe command. + + + These values can be used to customise the subscription. + + + + + x-bindings + + + A nested list each of whose entries is a map that may + contain fields (queue, exchange, key and arguments) + describing an AMQP 0-10 binding. + + + These bindings are established during resolution + independent of the create option. They are considered + logically part of the linking process rather than of + node creation. + + + + + - - 50 - and $w/temperature_f - $w/dewpoint > 5 - and $w/wind_speed_mph > 7 - and $w/wind_speed_mph < 20 ]]> - +
+
- We can specify this query in an x-binding to listen to messages that meet the criteria specified by the query: +
+ Address String Grammar - First Window: + This section provides a formal grammar for address strings. - -$ ./drain -f "xml; {link:{x-bindings:[{key:'weather', -arguments:{xquery:\"$(cat rdu.xquery )\"}}]}}" - + + Tokens + The following regular expressions define the tokens used + to parse address strings: + - In another window, let's create an XML message that meets the criteria in the query, and place it in the file rdu.xml: + + Grammar + The formal grammar for addresses is given below: + - - - Raleigh-Durham International Airport (KRDU) - 16 - 70 - 35 - + - Now let's use spout to send this message to the XML exchange: - Second Window: - -spout --content "$(cat rdu.xml)" xml/weather - + + Address String Options + The address string options map supports the following parameters: + - Returning to the first window, we see that the message has been received: + [ / ] ; { + create: always | sender | receiver | never, + delete: always | sender | receiver | never, + assert: always | sender | receiver | never, + mode: browse | consume, + node: { + type: queue | topic, + durable: True | False, + x-declare: { ... ... }, + x-bindings: [, ... ] + }, + link: { + name: , + durable: True | False, + reliability: unreliable | at-most-once | at-least-once | exactly-once, + x-declare: { ... ... }, + x-bindings: [, ... ], + x-subscribe: { ... ... } + } + } + ]]> - - Raleigh-Durham International Airport (KRDU) - 16 - 40 - 35 -') ]]> - - + + + Create, Delete, and Assert Policies + The create, delete, and assert policies specify who should + perfom the associated action: + always: the action is performed by any messaging client + sender: the action is only performed by a sender + receiver: the action is only performed by a receiver + never: the action is never performed (this is the default) + + + + Node-Type + The node-type is one of: + topic: in the AMQP 0-10 + mapping, a topic node defaults to the topic exchange, x-declare + may be used to specify other exchange types + queue: this is the default node-type +
- +
- +
+ Sender Capacity and Replay + + The send method of a sender has an optional second parameter + that controls whether the send call is synchronous or not. A + synchronous send call will block until the broker has confirmed + receipt of the message. An asynchronous send call will return + before the broker confirms receipt of the message, allowing for + example further send calls to be made without waiting for a + roundtrip to the broker for each message. This is desirable where + increased throughput is important. + + The sender maintains a list of sent messages whose receipt + has yet to be confirmed by the broker. The maximum number of such + messages that it will hold is defined by the capacity of the + sender, which can be set by the application. If an application + tries to send with a sender whose capacity is already fully used + up, the send call will block waiting for capacity regardless of + the value of the sync flag. + + The sender can be queried for the available space (i.e. the + unused capacity), and for the current count of unsettled messages + (i.e. those held in the replay list pending confirmation by the + server). When the unsettled count is zero, all messages on that + sender have been successfully sent. + + If the connection fails and is transparently reconnected + (see for details on how to control + this feature), the unsettled messages for each sender over that + connection will be re-transmitted. This provides a transparent + level of reliability. This feature can be controlled through the + link's reliability as defined in the address (see + ). At present only + at-least-once guarantees are offered. +
-
- Address String Options - Reference +
+ Receiver Capacity (Prefetch) - - Address String Options - - - - - - - option - value - semantics - - - - - - assert - - - one of: always, never, sender or receiver - - - Asserts that the properties specified in the node option - match whatever the address resolves to. If they do not, - resolution fails and an exception is raised. - - - - - - create - - - one of: always, never, sender or receiver - - - Creates the node to which an address refers if it does - not exist. No error is raised if the node does - exist. The details of the node may be specified in the - node option. - - - - - delete - - - one of: always, never, sender or receiver - - - Delete the node when the sender or receiver is closed. - - - - - node - - - A nested map containing the entries shown in . - - - Specifies properties of the node to which the address - refers. These are used in conjunction with the assert or - create options. - - - - - link - - - A nested map containing the entries shown in . - - - Used to control the establishment of a conceptual link - from the client application to or from the target/source - address. - - - - - mode - - - one of: browse, consume - - - This option is only of relevance for source addresses - that resolve to a queue. If browse is specified the - messages delivered to the receiver are left on the queue - rather than being removed. If consume is specified the - normal behaviour applies; messages are removed from the - queue once the client acknowledges their receipt. - - - - -
- - - - Node Properties - - - - - - - property - value - semantics - - - - - - type - - - topic, queue - - - Indicates the type of the node. - - - - - durable - - - True, False - - - Indicates whether the node survives a loss of - volatile storage e.g. if the broker is restarted. - - - - - x-declare - - - A nested map whose values correspond to the valid fields - on an AMQP 0-10 queue-declare or exchange-declare - command. - - - These values are used to fine tune the creation or - assertion process. Note however that they are protocol - specific. - - - - - x-bindings - - - A nested list in which each binding is represented by - a map. The entries of the map for a binding contain - the fields that describe an AMQP 0-10 binding. Here is - the format for x-bindings: - -, - queue: , - key: , - arguments: { - : , - ..., - : } - }, - ... -] -]]> - - - In conjunction with the create option, each of these - bindings is established as the address is resolved. In - conjunction with the assert option, the existence of - each of these bindings is verified during - resolution. Again, these are protocol specific. - - - - -
- - - Link Properties - - - - - - - option - value - semantics - - - - - - reliability - - - one of: unreliable, at-least-once, at-most-once, exactly-once - - - Reliability indicates the level of reliability that - the sender or receiver. unreliable - and at-most-once are currently - treated as synonyms, and allow messages to be lost if - a broker crashes or the connection to a broker is - lost. at-least-once guarantees that - a message is not lost, but duplicates may be - received. exactly-once guarantees - that a message is not lost, and is delivered precisely - once. Currently only unreliable - and at-least-once are supported. - If at-most-once is requested, - unreliable will be used and for durable messages on - durable queues there is the possibility that messages - will be redelivered; if exactly-once is requested, - at-most-once will be used and the application needs to - be able to deal with duplicates. - - - - - durable - - - True, False - - - Indicates whether the link survives a loss of - volatile storage e.g. if the broker is restarted. - - - - - x-declare - - - A nested map whose values correspond to the valid fields - of an AMQP 0-10 queue-declare command. - - - These values can be used to customise the subscription - queue in the case of receiving from an exchange. Note - however that they are protocol specific. - - - - - x-subscribe - - - A nested map whose values correspond to the valid fields - of an AMQP 0-10 message-subscribe command. - - - These values can be used to customise the subscription. - - - - - x-bindings - - - A nested list each of whose entries is a map that may - contain fields (queue, exchange, key and arguments) - describing an AMQP 0-10 binding. - - - These bindings are established during resolution - independent of the create option. They are considered - logically part of the linking process rather than of - node creation. - - - - - + By default, a receiver requests the next message from the + server in response to each fetch call, resulting in messages being + sent to the receiver one at a time. As in the case of sending, it + is often desirable to avoid this roundtrip for each message. This + can be achieved by allowing the receiver + to prefetch messages in anticipation of + fetch calls being made. The receiver needs to be able to store + these prefetched messages, the number it can hold is controlled by + the receivers capacity.
-
- -
- Address String Grammar - - This section provides a formal grammar for address strings. - - - Tokens - The following regular expressions define the tokens used - to parse address strings: - - - - Grammar - The formal grammar for addresses is given below: - - - - - - - Address String Options - The address string options map supports the following parameters: - - - [ / ] ; { - create: always | sender | receiver | never, - delete: always | sender | receiver | never, - assert: always | sender | receiver | never, - mode: browse | consume, - node: { - type: queue | topic, - durable: True | False, - x-declare: { ... ... }, - x-bindings: [, ... ] - }, - link: { - name: , - durable: True | False, - reliability: unreliable | at-most-once | at-least-once | exactly-once, - x-declare: { ... ... }, - x-bindings: [, ... ], - x-subscribe: { ... ... } - } -} -]]> +
+ Acknowledging Received Messages + + Applications that receive messages should acknowledge their + receipt by calling the session's acknowledge method. As in the + case of sending messages, acknowledged transfer of messages to + receivers provides at-least-once reliability, which means that the + loss of the connection or a client crash does not result in lost + messages; durable messages are not lost even if the broker is + restarted. + + Some cases may not require this however and the reliability can be + controlled through a link property in the address options (see + ). + + The acknowledge call acknowledges all messages received on + the session (i.e. all message that have been returned from a fetch + call on a receiver created on that session). + + The acknowledge call also support an optional parameter + controlling whether the call is synchronous or not. A synchronous + acknowledge will block until the server has confirmed that it has + received the acknowledgement. In the asynchronous case, when the + call returns there is not yet any guarantee that the server has + received and processed the acknowledgement. The session may be + queried for the number of unsettled acknowledgements; when that + count is zero all acknowledgements made for received messages have + been successful. - - Create, Delete, and Assert Policies - The create, delete, and assert policies specify who should - perfom the associated action: - always: the action is performed by any messaging client - sender: the action is only performed by a sender - receiver: the action is only performed by a receiver - never: the action is never performed (this is the default) - - - - Node-Type - The node-type is one of: - topic: in the AMQP 0-10 - mapping, a topic node defaults to the topic exchange, x-declare - may be used to specify other exchange types - queue: this is the default node-type - -
- - -
- -
- Sender Capacity and Replay - - The send method of a sender has an optional second parameter - that controls whether the send call is synchronous or not. A - synchronous send call will block until the broker has confirmed - receipt of the message. An asynchronous send call will return - before the broker confirms receipt of the message, allowing for - example further send calls to be made without waiting for a - roundtrip to the broker for each message. This is desirable where - increased throughput is important. - - The sender maintains a list of sent messages whose receipt - has yet to be confirmed by the broker. The maximum number of such - messages that it will hold is defined by the capacity of the - sender, which can be set by the application. If an application - tries to send with a sender whose capacity is already fully used - up, the send call will block waiting for capacity regardless of - the value of the sync flag. - - The sender can be queried for the available space (i.e. the - unused capacity), and for the current count of unsettled messages - (i.e. those held in the replay list pending confirmation by the - server). When the unsettled count is zero, all messages on that - sender have been successfully sent. - - If the connection fails and is transparently reconnected - (see for details on how to control - this feature), the unsettled messages for each sender over that - connection will be re-transmitted. This provides a transparent - level of reliability. This feature can be controlled through the - link's reliability as defined in the address (see - ). At present only - at-least-once guarantees are offered. -
- -
- Receiver Capacity (Prefetch) - - By default, a receiver requests the next message from the - server in response to each fetch call, resulting in messages being - sent to the receiver one at a time. As in the case of sending, it - is often desirable to avoid this roundtrip for each message. This - can be achieved by allowing the receiver - to prefetch messages in anticipation of - fetch calls being made. The receiver needs to be able to store - these prefetched messages, the number it can hold is controlled by - the receivers capacity. - -
- -
- Acknowledging Received Messages - - Applications that receive messages should acknowledge their - receipt by calling the session's acknowledge method. As in the - case of sending messages, acknowledged transfer of messages to - receivers provides at-least-once reliability, which means that the - loss of the connection or a client crash does not result in lost - messages; durable messages are not lost even if the broker is - restarted. - - Some cases may not require this however and the reliability can be - controlled through a link property in the address options (see - ). - - The acknowledge call acknowledges all messages received on - the session (i.e. all message that have been returned from a fetch - call on a receiver created on that session). - - The acknowledge call also support an optional parameter - controlling whether the call is synchronous or not. A synchronous - acknowledge will block until the server has confirmed that it has - received the acknowledgement. In the asynchronous case, when the - call returns there is not yet any guarantee that the server has - received and processed the acknowledgement. The session may be - queried for the number of unsettled acknowledgements; when that - count is zero all acknowledgements made for received messages have - been successful. - -
+
@@ -1536,39 +1536,39 @@ options := map C++: + Message message = session.nextReceiver().fetch(); + std::cout << message.getContent() << std::endl; + session.acknowledge(); // acknowledge message receipt + ]]> Python: + receiver1 = session.receiver(address1) + receiver1.capacity = 10 + receiver2 = session.receiver(address) + receiver2.capacity = 10 + message = session.next_receiver().fetch() + print message.content + session.acknowledge() + ]]> .NET C#: + Message message = new Message(); + message = session.NextReceiver().Fetch(); + Console.WriteLine("{0}", message.GetContent()); + session.Acknowledge(); + ]]>
@@ -1596,33 +1596,33 @@ session.Acknowledge(); Transactions C++: - - .NET C#: - - - -Connection connection = new Connection(broker); -Session session = connection.CreateTransactionalSession(); -... -if (smellsOk()) - session.Commit(); -else - session.Rollback(); - - + Connection connection(broker); + Session session = connection.createTransactionalSession(); + ... + if (smellsOk()) + session.commit(); + else + session.rollback(); + ]]> + + .NET C#: + + + + Connection connection = new Connection(broker); + Session session = connection.CreateTransactionalSession(); + ... + if (smellsOk()) + session.Commit(); + else + session.Rollback(); + + @@ -1637,231 +1637,231 @@ else broker is lost. - - Specifying Connection Options in C++, Python, and .NET + + Specifying Connection Options in C++, Python, and .NET - In C++, these options can be set using Connection::setOption() or by passing in a set of options to the constructor. The options can be passed in as a map or in string form: + In C++, these options can be set using Connection::setOption() or by passing in a set of options to the constructor. The options can be passed in as a map or in string form: - + -or + or - + - In Python, these options can be set as attributes of the connection or using named arguments in - the Connection constructor: + In Python, these options can be set as attributes of the connection or using named arguments in + the Connection constructor: - + -or + or - - - In .NET, these options can be set using Connection.SetOption() or by passing in a set of options to the constructor. The options can be passed in as a map or in string form: - - - -Connection connection= new Connection("localhost:5672", "{reconnect: true}"); -try { - connection.Open(); - !!! SNIP !!! - - - or - - - -Connection connection = new Connection("localhost:5672"); -connection.SetOption("reconnect", true); -try { - connection.Open(); - !!! SNIP !!! - - - See the reference documentation for details in each language. - + + + In .NET, these options can be set using Connection.SetOption() or by passing in a set of options to the constructor. The options can be passed in as a map or in string form: + - The following table lists the supported connection options. + + Connection connection= new Connection("localhost:5672", "{reconnect: true}"); + try { + connection.Open(); + !!! SNIP !!! + + + or + - - Connection Options - - - - - - - option name - value type - semantics - - - + + Connection connection = new Connection("localhost:5672"); + connection.SetOption("reconnect", true); + try { + connection.Open(); + !!! SNIP !!! + - - - username - - - string - - - The username to use when authenticating to the broker. - - - - - password - - - string - - - The password to use when authenticating to the broker. - - - - - sasl_mechanisms - - - string - - - The specific SASL mechanisms to use with the python - client when authenticating to the broker. The value - is a space separated list. - - + See the reference documentation for details in each language. + + The following table lists the supported connection options. - - - reconnect - - - boolean - - - Transparently reconnect if the connection is lost. - - - - - reconnect_timeout - - - integer - - - Total number of seconds to continue reconnection attempts before giving up and raising an exception. - - - - - reconnect_limit - - - integer - - - Maximum number of reconnection attempts before giving up and raising an exception. - - - - - reconnect_interval_min - - - integer representing time in seconds - - - Minimum number of seconds between reconnection attempts. The first reconnection attempt is made immediately; if that fails, the first reconnection delay is set to the value of reconnect_interval_min; if that attempt fails, the reconnect interval increases exponentially until a reconnection attempt succeeds or reconnect_interval_max is reached. - - - - - reconnect_interval_max - - - integer representing time in seconds - - - Maximum reconnect interval. - - - - - reconnect_interval - - - integer representing time in seconds - - - Sets both reconnection_interval_min and reconnection_interval_max to the same value. - - +
+ Connection Options + + + + + + + option name + value type + semantics + + + + + + + username + + + string + + + The username to use when authenticating to the broker. + + + + + password + + + string + + + The password to use when authenticating to the broker. + + + + + sasl_mechanisms + + + string + + + The specific SASL mechanisms to use with the python + client when authenticating to the broker. The value + is a space separated list. + + + + + + + reconnect + + + boolean + + + Transparently reconnect if the connection is lost. + + + + + reconnect_timeout + + + integer + + + Total number of seconds to continue reconnection attempts before giving up and raising an exception. + + + + + reconnect_limit + + + integer + + + Maximum number of reconnection attempts before giving up and raising an exception. + + + + + reconnect_interval_min + + + integer representing time in seconds + + + Minimum number of seconds between reconnection attempts. The first reconnection attempt is made immediately; if that fails, the first reconnection delay is set to the value of reconnect_interval_min; if that attempt fails, the reconnect interval increases exponentially until a reconnection attempt succeeds or reconnect_interval_max is reached. + + + + + reconnect_interval_max + + + integer representing time in seconds + + + Maximum reconnect interval. + + + + + reconnect_interval + + + integer representing time in seconds + + + Sets both reconnection_interval_min and reconnection_interval_max to the same value. + + - - - heartbeat - - - integer representing time in seconds - - - Requests that heartbeats be sent every N seconds. If two - successive heartbeats are missed the connection is - considered to be lost. - - - - - protocol - - - string - - - Sets the underlying protocol used. The default option is 'tcp'. To enable ssl, set to 'ssl'. The C++ client additionally supports 'rdma'. - - - - - tcp-nodelay - - - boolean - - - Set tcp no-delay, i.e. disable Nagle algorithm. [C++ only] - - - - -
+ + + heartbeat + + + integer representing time in seconds + + + Requests that heartbeats be sent every N seconds. If two + successive heartbeats are missed the connection is + considered to be lost. + + + + + protocol + + + string + + + Sets the underlying protocol used. The default option is 'tcp'. To enable ssl, set to 'ssl'. The C++ client additionally supports 'rdma'. + + + + + tcp-nodelay + + + boolean + + + Set tcp no-delay, i.e. disable Nagle algorithm. [C++ only] + + + + + @@ -1877,57 +1877,57 @@ try { Unlike JMS, there is not a specific message type for map messages. - - - Note that the Qpid JMS client supports MapMessages whose values can be nested maps or lists. This is not standard JMS behaviour. - - - Specific language support for map and list objects are shown in the following table. - - - Map and List Representation in Supported Languages - - - - Language - map - list - - - - - Python - dict - list - - - C++ - Variant::Map - Variant::List - - - Java - MapMessage -   - - - .NET - Dictionary<string, object> - Collection<object> - - - -
- - In all languages, messages are encoded using AMQP's portable datatypes. + + + Note that the Qpid JMS client supports MapMessages whose values can be nested maps or lists. This is not standard JMS behaviour. + + + Specific language support for map and list objects are shown in the following table. + + + Map and List Representation in Supported Languages + + + + Language + map + list + + + + + Python + dict + list + + + C++ + Variant::Map + Variant::List + + + Java + MapMessage +   + + + .NET + Dictionary<string, object> + Collection<object> + + + +
+ + In all languages, messages are encoded using AMQP's portable datatypes. - Because of the differences in type systems among - languages, the simplest way to provide portable messages is to - rely on maps, lists, strings, 64 bit signed integers, and - doubles for messages that need to be exchanged across languages - and platforms. + Because of the differences in type systems among + languages, the simplest way to provide portable messages is to + rely on maps, lists, strings, 64 bit signed integers, and + doubles for messages that need to be exchanged across languages + and platforms.
@@ -1938,55 +1938,55 @@ try { Sending Qpid Maps and Lists in Python + from qpid.messaging import * + # !!! SNIP !!! + + content = {'Id' : 987654321, 'name' : 'Widget', 'percent' : 0.99} + content['colours'] = ['red', 'green', 'white'] + content['dimensions'] = {'length' : 10.2, 'width' : 5.1,'depth' : 2.0}; + content['parts'] = [ [1,2,5], [8,2,5] ] + content['specs'] = {'colors' : content['colours'], + 'dimensions' : content['dimensions'], + 'parts' : content['parts'] } + message = Message(content=content) + sender.send(message) + ]]> - The following table shows the datatypes that can be sent in a Python map message, - and the corresponding datatypes that will be received by clients in Java or C++. + The following table shows the datatypes that can be sent in a Python map message, + and the corresponding datatypes that will be received by clients in Java or C++. - Python Datatypes in Maps - - - - Python Datatype - → C++ - → Java - - - - boolboolboolean - intint64long - longint64long - floatdoubledouble - unicodestringjava.lang.String - uuidqpid::types::Uuidjava.util.UUID - dictVariant::Mapjava.util.Map - listVariant::Listjava.util.List - - -
+ Python Datatypes in Maps + + + + Python Datatype + → C++ + → Java + + + + boolboolboolean + intint64long + longint64long + floatdoubledouble + unicodestringjava.lang.String + uuidqpid::types::Uuidjava.util.UUID + dictVariant::Mapjava.util.Map + listVariant::Listjava.util.List + + +
-
+
Qpid Maps and Lists in C++ @@ -1998,52 +1998,52 @@ sender.send(message) Sending Qpid Maps and Lists in C++ - + The following table shows the datatypes that can be sent @@ -2051,32 +2051,32 @@ sender.send(message, true); will be received by clients in Java and Python. - C++ Datatypes in Maps - - - - C++ Datatype - → Python - → Java - - - - boolboolboolean - uint16int | longshort - uint32int | longint - uint64int | longlong - int16int | longshort - int32int | longint - int64int | longlong - floatfloatfloat - doublefloatdouble - stringunicodejava.lang.String - qpid::types::Uuiduuidjava.util.UUID - Variant::Mapdictjava.util.Map - Variant::Listlistjava.util.List - - -
+ C++ Datatypes in Maps + + + + C++ Datatype + → Python + → Java + + + + boolboolboolean + uint16int | longshort + uint32int | longint + uint64int | longlong + int16int | longshort + int32int | longint + int64int | longlong + floatfloatfloat + doublefloatdouble + stringunicodejava.lang.String + qpid::types::Uuiduuidjava.util.UUID + Variant::Mapdictjava.util.Map + Variant::Listlistjava.util.List + + +
@@ -2090,74 +2090,74 @@ sender.send(message, true); - + Sending Qpid Maps and Lists in .NET C# - content = new Dictionary(); -Dictionary subMap = new Dictionary(); -Collection colors = new Collection(); + Dictionary content = new Dictionary(); + Dictionary subMap = new Dictionary(); + Collection colors = new Collection(); -// add simple types -content["id"] = 987654321; -content["name"] = "Widget"; -content["percent"] = 0.99; + // add simple types + content["id"] = 987654321; + content["name"] = "Widget"; + content["percent"] = 0.99; -// add nested amqp/map -subMap["name"] = "Smith"; -subMap["number"] = 354; -content["nestedMap"] = subMap; + // add nested amqp/map + subMap["name"] = "Smith"; + subMap["number"] = 354; + content["nestedMap"] = subMap; -// add an amqp/list -colors.Add("red"); -colors.Add("green"); -colors.Add("white"); -content["colorsList"] = colors; + // add an amqp/list + colors.Add("red"); + colors.Add("green"); + colors.Add("white"); + content["colorsList"] = colors; -// add one of each supported amqp data type -bool mybool = true; -content["mybool"] = mybool; + // add one of each supported amqp data type + bool mybool = true; + content["mybool"] = mybool; -byte mybyte = 4; -content["mybyte"] = mybyte; + byte mybyte = 4; + content["mybyte"] = mybyte; -UInt16 myUInt16 = 5; -content["myUInt16"] = myUInt16; + UInt16 myUInt16 = 5; + content["myUInt16"] = myUInt16; -UInt32 myUInt32 = 6; -content["myUInt32"] = myUInt32; + UInt32 myUInt32 = 6; + content["myUInt32"] = myUInt32; -UInt64 myUInt64 = 7; -content["myUInt64"] = myUInt64; + UInt64 myUInt64 = 7; + content["myUInt64"] = myUInt64; -char mychar = 'h'; -content["mychar"] = mychar; + char mychar = 'h'; + content["mychar"] = mychar; -Int16 myInt16 = 9; -content["myInt16"] = myInt16; + Int16 myInt16 = 9; + content["myInt16"] = myInt16; -Int32 myInt32 = 10; -content["myInt32"] = myInt32; + Int32 myInt32 = 10; + content["myInt32"] = myInt32; -Int64 myInt64 = 11; -content["myInt64"] = myInt64; + Int64 myInt64 = 11; + content["myInt64"] = myInt64; -Single mySingle = (Single)12.12; -content["mySingle"] = mySingle; + Single mySingle = (Single)12.12; + content["mySingle"] = mySingle; -Double myDouble = 13.13; -content["myDouble"] = myDouble; + Double myDouble = 13.13; + content["myDouble"] = myDouble; -Guid myGuid = new Guid("000102030405060708090a0b0c0d0e0f"); -content["myGuid"] = myGuid; + Guid myGuid = new Guid("000102030405060708090a0b0c0d0e0f"); + content["myGuid"] = myGuid; -Message message = new Message(content); -Send(message, true); -]]> + Message message = new Message(content); + Send(message, true); + ]]> @@ -2165,45 +2165,45 @@ Send(message, true); - Datatype Mapping between C++ and .NET binding - - - - C++ Datatype - → .NET binding - - - - voidnullptr - boolbool - uint8byte - uint16UInt16 - uint32UInt32 - uint64UInt64 - uint8char - int16Int16 - int32Int32 - int64Int64 - floatSingle - doubleDouble - stringstring - - Strings are currently interpreted only with UTF-8 encoding. - - qpid::types::UuidGuid - Variant::Map]]> - - Variant::List]]> - - - -
- - - - - - + Datatype Mapping between C++ and .NET binding + + + + C++ Datatype + → .NET binding + + + + voidnullptr + boolbool + uint8byte + uint16UInt16 + uint32UInt32 + uint64UInt64 + uint8char + int16Int16 + int32Int32 + int64Int64 + floatSingle + doubleDouble + stringstring + + Strings are currently interpreted only with UTF-8 encoding. + + qpid::types::UuidGuid + Variant::Map]]> + + Variant::List]]> + + + + + + + + + +
The Request / Response Pattern @@ -2230,15 +2230,15 @@ Send(message, true); + Message request = receiver.fetch(); + const Address& address = request.getReplyTo(); // Get "reply-to" from request ... + if (address) { + Sender sender = session.createSender(address); // ... send response to "reply-to" + Message response("pong!"); + sender.send(response); + session.acknowledge(); + } + ]]> The client creates a sender for the service queue, and also creates a response queue that is deleted when the @@ -2247,18 +2247,18 @@ if (address) { #, it is given a unique name. " << response.getContent() << std::endl; -]]> + Message request; + request.setReplyTo(responseQueue); + request.setContent("ping"); + sender.send(request); + Message response = receiver.fetch(); + std::cout << request.getContent() << " -> " << response.getContent() << std::endl; + ]]> The client sends the string ping to the server. The server sends the response @@ -2266,12 +2266,12 @@ std::cout << request.getContent() << " -> " << response.getContent() << std::end replyTo property. - +
@@ -2279,109 +2279,109 @@ std::cout << request.getContent() << " -> " << response.getContent() << std::end Performance Tips - + Consider prefetching messages for receivers (see ). This helps eliminate roundtrips and increases throughput. Prefetch is disabled by default, and enabling it is the most effective means of improving throughput of received messages. - - + + Send messages asynchronously. Again, this helps eliminate roundtrips and increases throughput. The C++ and .NET clients send asynchronously by default, however the python client defaults to synchronous sends. - - + + Acknowledge messages in batches (see ). Rather than acknowledging each message individually, consider issuing acknowledgements after n messages and/or after a particular duration has elapsed. - - + + Tune the sender capacity (see ). If the capacity is too low the sender may block waiting for the broker to confirm receipt of messages, before it can free up more capacity. - - + + If you are setting a reply-to address on messages being sent by the c++ client, make sure the address type is set to either queue or topic as appropriate. This avoids the client having to determine which type of node is being refered to, which is required when hanling reply-to in AMQP 0-10. - - - For latency sensitive applications, setting tcp-nodelay - on qpidd and on client connections can help reduce the - latency. - + + + For latency sensitive applications, setting tcp-nodelay + on qpidd and on client connections can help reduce the + latency. + -
- Cluster Failover +
+ Cluster Failover - The messaging broker can be run in clustering mode, which provides high reliability through replicating state between brokers in the cluster. If one broker in a cluster fails, clients can choose another broker in the cluster and continue their work. Each broker in the cluster also advertises the addresses of all known brokers + The messaging broker can be run in clustering mode, which provides high reliability through replicating state between brokers in the cluster. If one broker in a cluster fails, clients can choose another broker in the cluster and continue their work. Each broker in the cluster also advertises the addresses of all known brokers -This is done via the amq.failover exchange in AMQP 0-10 + This is done via the amq.failover exchange in AMQP 0-10 -. A client can use this information to dynamically keep the list of reconnection urls up to date. + . A client can use this information to dynamically keep the list of reconnection urls up to date. - In C++, the FailoverUpdates class provides this functionality: + In C++, the FailoverUpdates class provides this functionality: - - Tracking cluster membership + + Tracking cluster membership - In C++: + In C++: - -... -Connection connection("localhost:5672"); -connection.setOption("reconnect", true); -try { - connection.open(); - std::auto_ptr updates(new FailoverUpdates(connection)); -]]> + + ... + Connection connection("localhost:5672"); + connection.setOption("reconnect", true); + try { + connection.open(); + std::auto_ptr updates(new FailoverUpdates(connection)); + ]]> - In python: + In python: - + - - In .NET C#: - + + In .NET C#: + - -using Org.Apache.Qpid.Messaging; -... -connection = new Connection("localhost:5672"); -connection.SetOption("reconnect", true); -try { - connection.Open(); - FailoverUpdates failover = new FailoverUpdates(connection); + + using Org.Apache.Qpid.Messaging; + ... + connection = new Connection("localhost:5672"); + connection.SetOption("reconnect", true); + try { + connection.Open(); + FailoverUpdates failover = new FailoverUpdates(connection); - + - -
+ +
-
+
Logging To simplify debugging, Qpid provides a logging facility @@ -2389,72 +2389,72 @@ try {
Logging in C++ - - The Qpidd broker and C++ clients can both use environment variables to enable logging. Linux and Windows systems use the same named environment variables and values. - - Use QPID_LOG_ENABLE to set the level of logging you are interested in (trace, debug, info, notice, warning, error, or critical): - + + The Qpidd broker and C++ clients can both use environment variables to enable logging. Linux and Windows systems use the same named environment variables and values. + + Use QPID_LOG_ENABLE to set the level of logging you are interested in (trace, debug, info, notice, warning, error, or critical): + - -export QPID_LOG_ENABLE="warning+" - - - The Qpidd broker and C++ clients use QPID_LOG_OUTPUT to determine where logging output should be sent. This is either a file name or the special values stderr, stdout, or syslog: - + + export QPID_LOG_ENABLE="warning+" + + + The Qpidd broker and C++ clients use QPID_LOG_OUTPUT to determine where logging output should be sent. This is either a file name or the special values stderr, stdout, or syslog: + - -export QPID_LOG_TO_FILE="/tmp/myclient.out" - + + export QPID_LOG_TO_FILE="/tmp/myclient.out" + - - From a Windows command prompt, use the following command format to set the environment variables: - + + From a Windows command prompt, use the following command format to set the environment variables: + - -set QPID_LOG_ENABLE=warning+ -set QPID_LOG_TO_FILE=D:\tmp\myclient.out - -
+ + set QPID_LOG_ENABLE=warning+ + set QPID_LOG_TO_FILE=D:\tmp\myclient.out + +
-
- Logging in Python - - The Python client library supports logging using the standard Python logging module. The easiest way to do logging is to use the basicConfig(), which reports all warnings and errors: - +
+ Logging in Python + + The Python client library supports logging using the standard Python logging module. The easiest way to do logging is to use the basicConfig(), which reports all warnings and errors: + -from logging import basicConfig -basicConfig() - - - Qpidd also provides a convenience method that makes it easy to specify the level of logging desired. For instance, the following code enables logging at the DEBUG level: - + from logging import basicConfig + basicConfig() + + + Qpidd also provides a convenience method that makes it easy to specify the level of logging desired. For instance, the following code enables logging at the DEBUG level: + -from qpid.log import enable, DEBUG -enable("qpid.messaging.io", DEBUG) - - - For more information on Python logging, see http://docs.python.org/lib/node425.html. For more information on Qpid logging, use $ pydoc qpid.log. - -
-
+ from qpid.log import enable, DEBUG + enable("qpid.messaging.io", DEBUG) + + + For more information on Python logging, see http://docs.python.org/lib/node425.html. For more information on Qpid logging, use $ pydoc qpid.log. + +
+ -
- The AMQP 0-10 mapping +
+ The AMQP 0-10 mapping - - This section describes the AMQP 0-10 mapping for the Qpid - Messaging API. - - + + This section describes the AMQP 0-10 mapping for the Qpid + Messaging API. + + The interaction with the broker triggered by creating a sender or receiver depends on what the specified address resolves to. Where the node type is not specified in the address, the client queries the broker to determine whether it refers to a queue or an exchange. - - + + When sending to a queue, the queue's name is set as the routing key and the message is transfered to the default (or nameless) exchange. When sending to an exchange, the message @@ -2571,13 +2571,13 @@ enable("qpid.messaging.io", DEBUG) The following table shows how Qpid Messaging API message - properties are mapped to AMQP 0-10 message properties and - delivery properties. In this table msg - refers to the Message class defined in the Qpid Messaging API, - mp refers to an AMQP 0-10 - message-properties struct, and - dp refers to an AMQP 0-10 - delivery-properties struct. + properties are mapped to AMQP 0-10 message properties and + delivery properties. In this table msg + refers to the Message class defined in the Qpid Messaging API, + mp refers to an AMQP 0-10 + message-properties struct, and + dp refers to an AMQP 0-10 + delivery-properties struct. Mapping to AMQP 0-10 Message Properties @@ -2589,13 +2589,13 @@ enable("qpid.messaging.io", DEBUG) Python API C++ API - - - The .NET Binding for C++ Messaging provides all the - message and delivery properties described in the C++ API. - See . - - + + + The .NET Binding for C++ Messaging provides all the + message and delivery properties described in the C++ API. + See . + + AMQP 0-10 PropertyIn these entries, mp refers to an AMQP message property, and dp refers to an AMQP delivery property. @@ -2693,12 +2693,12 @@ enable("qpid.messaging.io", DEBUG) a received message. -try: - msg = receiver.fetch(timeout=1) - if "x-amqp-0-10.timestamp" in msg.properties: - print("Timestamp=%s" % str(msg.properties["x-amqp-0-10.timestamp"])) -except Empty: - pass + try: + msg = receiver.fetch(timeout=1) + if "x-amqp-0-10.timestamp" in msg.properties: + print("Timestamp=%s" % str(msg.properties["x-amqp-0-10.timestamp"])) + except Empty: + pass @@ -2707,12 +2707,12 @@ except Empty: The same example, except in C++. -messaging::Message msg; -if (receiver.fetch(msg, messaging::Duration::SECOND*1)) { - if (msg.getProperties().find("x-amqp-0-10.timestamp") != msg.getProperties().end()) { - - } -} + messaging::Message msg; + if (receiver.fetch(msg, messaging::Duration::SECOND*1)) { + if (msg.getProperties().find("x-amqp-0-10.timestamp") != msg.getProperties().end()) { + + } + } @@ -2745,54 +2745,54 @@ if (receiver.fetch(msg, messaging::Duration::SECOND*1)) { "Hello world!" in Java -package org.apache.qpid.example.jmsexample.hello; + package org.apache.qpid.example.jmsexample.hello; -import javax.jms.*; -import javax.naming.Context; -import javax.naming.InitialContext; -import java.util.Properties; + import javax.jms.*; + import javax.naming.Context; + import javax.naming.InitialContext; + import java.util.Properties; -public class Hello { + public class Hello { - public Hello() { - } + public Hello() { + } - public static void main(String[] args) { - Hello producer = new Hello(); - producer.runTest(); - } + public static void main(String[] args) { + Hello producer = new Hello(); + producer.runTest(); + } - private void runTest() { - try { - Properties properties = new Properties(); - properties.load(this.getClass().getResourceAsStream("hello.properties")); - Context context = new InitialContext(properties); + private void runTest() { + try { + Properties properties = new Properties(); + properties.load(this.getClass().getResourceAsStream("hello.properties")); + Context context = new InitialContext(properties); - ConnectionFactory connectionFactory + ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("qpidConnectionfactory"); - Connection connection = connectionFactory.createConnection(); - connection.start(); + Connection connection = connectionFactory.createConnection(); + connection.start(); - Session session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE); - Destination destination = (Destination) context.lookup("topicExchange"); + Session session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE); + Destination destination = (Destination) context.lookup("topicExchange"); - MessageProducer messageProducer = session.createProducer(destination); - MessageConsumer messageConsumer = session.createConsumer(destination); + MessageProducer messageProducer = session.createProducer(destination); + MessageConsumer messageConsumer = session.createConsumer(destination); - TextMessage message = session.createTextMessage("Hello world!"); - messageProducer.send(message); + TextMessage message = session.createTextMessage("Hello world!"); + messageProducer.send(message); - message = (TextMessage)messageConsumer.receive(); - System.out.println(message.getText()); + message = (TextMessage)messageConsumer.receive(); + System.out.println(message.getText()); - connection.close(); - context.close(); - } - catch (Exception exp) { - exp.printStackTrace(); - } - } -} + connection.close(); + context.close(); + } + catch (Exception exp) { + exp.printStackTrace(); + } + } + } @@ -2839,16 +2839,16 @@ public class Hello { JNDI Properties File for "Hello world!" example - -java.naming.factory.initial - = org.apache.qpid.jndi.PropertiesFileInitialContextFactory - -# connectionfactory.[jndiname] = [ConnectionURL] -connectionfactory.qpidConnectionfactory - = amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:5672' -# destination.[jndiname] = [address_string] -destination.topicExchange = amq.topic - + + java.naming.factory.initial + = org.apache.qpid.jndi.PropertiesFileInitialContextFactory + + # connectionfactory.[jndiname] = [ConnectionURL] + connectionfactory.qpidConnectionfactory + = amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:5672' + # destination.[jndiname] = [address_string] + destination.topicExchange = amq.topic + @@ -2881,16 +2881,16 @@ destination.topicExchange = amq.topic JNDI Properties File - + The following sections describe the JNDI properties that Qpid uses. @@ -3017,15 +3017,15 @@ destination.topicExchange = amq.topic maxprefetch - integer + integer - + The maximum number of pre-fetched messages per consumer. If not specified, default value of 500 is used. - - + + Note: You can also set the default per-consumer prefetch value on a client-wide basis by configuring the client using Java system properties. - + @@ -3033,10 +3033,10 @@ destination.topicExchange = amq.topic sync_publish - {'persistent' | 'all'} + {'persistent' | 'all'} - A sync command is sent after every persistent message to guarantee that it has been received; if the value is 'persistent', this is done only for persistent messages. + A sync command is sent after every persistent message to guarantee that it has been received; if the value is 'persistent', this is done only for persistent messages. @@ -3044,47 +3044,47 @@ destination.topicExchange = amq.topic sync_ack - Boolean + Boolean - A sync command is sent after every acknowledgement to guarantee that it has been received. + A sync command is sent after every acknowledgement to guarantee that it has been received. - + use_legacy_map_msg_format - Boolean + Boolean - If you are using JMS Map messages and deploying a new client with any JMS client older than 0.8 release, you must set this to true to ensure the older clients can understand the map message encoding. + If you are using JMS Map messages and deploying a new client with any JMS client older than 0.8 release, you must set this to true to ensure the older clients can understand the map message encoding. - + failover - {'singlebroker' | 'roundrobin' | 'failover_exchange' | 'nofailover' | '<class>'} + {'singlebroker' | 'roundrobin' | 'failover_exchange' | 'nofailover' | '<class>'} - - This option controls failover behaviour. The method singlebroker uses only the first broker in the list, - roundrobin will try each broker given in the broker list until a connection is established, - failover_exchange connects to the initial broker given in the broker URL and will receive membership updates - via the failover exchange. nofailover disables all retry and failover logic. Any other value is interpreted as a - classname which must implement the org.apache.qpid.jms.failover.FailoverMethod interface. - - - The broker list options retries and connectdelay (described below) determine the number of times a - connection to a broker will be retried and the the length of time to wait between successive connection attempts before moving on to - the next broker in the list. The failover option cyclecount controls the number of times to loop through the list of - available brokers before finally giving up. - - - Defaults to roundrobin if the brokerlist contains multiple brokers, or singlebroker otherwise. - + + This option controls failover behaviour. The method singlebroker uses only the first broker in the list, + roundrobin will try each broker given in the broker list until a connection is established, + failover_exchange connects to the initial broker given in the broker URL and will receive membership updates + via the failover exchange. nofailover disables all retry and failover logic. Any other value is interpreted as a + classname which must implement the org.apache.qpid.jms.failover.FailoverMethod interface. + + + The broker list options retries and connectdelay (described below) determine the number of times a + connection to a broker will be retried and the the length of time to wait between successive connection attempts before moving on to + the next broker in the list. The failover option cyclecount controls the number of times to loop through the list of + available brokers before finally giving up. + + + Defaults to roundrobin if the brokerlist contains multiple brokers, or singlebroker otherwise. + @@ -3108,29 +3108,29 @@ destination.topicExchange = amq.topic Broker Lists - A broker list can specify properties to be used when connecting to the broker, such as security options. This broker list specifies options for a Kerberos connection using GSSAPI: - + A broker list can specify properties to be used when connecting to the broker, such as security options. This broker list specifies options for a Kerberos connection using GSSAPI: + - This broker list specifies SSL options: + This broker list specifies SSL options: - + - - This broker list specifies two brokers using the connectdelay and retries broker options. It also illustrates the failover connection URL - property. - + + This broker list specifies two brokers using the connectdelay and retries broker options. It also illustrates the failover connection URL + property. + - + amqp://guest:guest@/test?failover='roundrobin?cyclecount='2'' + &brokerlist='tcp://ip1:5672?retries='5'&connectdelay='2000';tcp://ip2:5672?retries='5'&connectdelay='2000'' + ]]> The following broker list options are supported. @@ -3188,10 +3188,10 @@ amqp://guest:guest@/test?failover='roundrobin?cyclecount='2'' sasl_encryption - Boolean + Boolean - If sasl_encryption='true', the JMS client attempts to negotiate a security layer with the broker using GSSAPI to encrypt the connection. Note that for this to happen, GSSAPI must be selected as the sasl_mech. + If sasl_encryption='true', the JMS client attempts to negotiate a security layer with the broker using GSSAPI to encrypt the connection. Note that for this to happen, GSSAPI must be selected as the sasl_mech. @@ -3295,7 +3295,7 @@ amqp://guest:guest@/test?failover='roundrobin?cyclecount='2'' - If multiple certificates are present in the keystore, the alias will be used to extract the correct certificate. + If multiple certificates are present in the keystore, the alias will be used to extract the correct certificate. @@ -3306,7 +3306,7 @@ amqp://guest:guest@/test?failover='roundrobin?cyclecount='2'' integer - The number of times to retry connection to each broker in the broker list. Defaults to 1. + The number of times to retry connection to each broker in the broker list. Defaults to 1. @@ -3353,13 +3353,13 @@ amqp://guest:guest@/test?failover='roundrobin?cyclecount='2'' Java JMS Message Properties The following table shows how Qpid Messaging API message - properties are mapped to AMQP 0-10 message properties and - delivery properties. In this table msg - refers to the Message class defined in the Qpid Messaging API, - mp refers to an AMQP 0-10 - message-properties struct, and - dp refers to an AMQP 0-10 - delivery-properties struct. + properties are mapped to AMQP 0-10 message properties and + delivery properties. In this table msg + refers to the Message class defined in the Qpid Messaging API, + mp refers to an AMQP 0-10 + message-properties struct, and + dp refers to an AMQP 0-10 + delivery-properties struct.
Java JMS Mapping to AMQP 0-10 Message Properties @@ -3418,54 +3418,54 @@ amqp://guest:guest@/test?failover='roundrobin?cyclecount='2'' Sending a Java JMS MapMessage - colors = new ArrayList(); -colors.add("red"); -colors.add("green"); -colors.add("white"); -m.setObject("colours", colors); - -Map dimensions = new HashMap(); -dimensions.put("length",10.2); -dimensions.put("width",5.1); -dimensions.put("depth",2.0); -m.setObject("dimensions",dimensions); - -List> parts = new ArrayList>(); -parts.add(Arrays.asList(new Integer[] {1,2,5})); -parts.add(Arrays.asList(new Integer[] {8,2,5})); -m.setObject("parts", parts); - -Map specs = new HashMap(); -specs.put("colours", colors); -specs.put("dimensions", dimensions); -specs.put("parts", parts); -m.setObject("specs",specs); - -producer.send(m); - ]]> + colors = new ArrayList(); + colors.add("red"); + colors.add("green"); + colors.add("white"); + m.setObject("colours", colors); + + Map dimensions = new HashMap(); + dimensions.put("length",10.2); + dimensions.put("width",5.1); + dimensions.put("depth",2.0); + m.setObject("dimensions",dimensions); + + List> parts = new ArrayList>(); + parts.add(Arrays.asList(new Integer[] {1,2,5})); + parts.add(Arrays.asList(new Integer[] {8,2,5})); + m.setObject("parts", parts); + + Map specs = new HashMap(); + specs.put("colours", colors); + specs.put("dimensions", dimensions); + specs.put("parts", parts); + m.setObject("specs",specs); + + producer.send(m); + ]]> The following table shows the datatypes that can be sent in a MapMessage, and the corresponding datatypes that will be received by clients in Python or C++. @@ -3509,14 +3509,14 @@ producer.send(m); log4j Logging Properties + log4j.appender.console=org.apache.log4j.ConsoleAppender + log4j.appender.console.Threshold=all + log4j.appender.console.layout=org.apache.log4j.PatternLayout + log4j.appender.console.layout.ConversionPattern=%t %d %p [%c{4}] %m%n + ]]> @@ -3530,420 +3530,420 @@ log4j.appender.console.layout.ConversionPattern=%t %d %p [%c{4}] %m%n JVM level using JVM arguments : Configuration that affects all connections, sessions, consumers and producers created within that JVM. - + Ex. -Dmax_prefetch=1000 property specifies the message credits to use. Connection level using Connection/Broker properties : Affects the respective connection and sessions, consumers and produces created by that connection. - + Ex. amqp://guest:guest@test/test?max_prefetch='1000' - &brokerlist='tcp://localhost:5672' - property specifies the message credits to use. This overrides any value specified via the JVM argument max_prefetch. + &brokerlist='tcp://localhost:5672' + property specifies the message credits to use. This overrides any value specified via the JVM argument max_prefetch. Please refer to the section for a complete list of all properties and how to use them. Destination level using Addressing options : Affects the producer(s) and consumer(s) created using the respective destination. - + Ex. my-queue; {create: always, link:{capacity: 10}}, where capacity option specifies the message credits to use. This overrides any connection level configuration. Please refer to the section for a complete understanding of addressing and it's various options. -Some of these config options are available at all three levels (Ex. max_prefetch), while others are available only at JVM or connection level. + Some of these config options are available at all three levels (Ex. max_prefetch), while others are available only at JVM or connection level.
Qpid JVM Arguments -
- Config Options For Connection Behaviour - - - - Property Name - Type - Default Value - Description - - - - - qpid.amqp.version - string - 0-10 - Sets the AMQP version to be used - currently supports one of {0-8,0-9,0-91,0-10}.The client will begin negotiation at the specified version and only negotiate downwards if the Broker does not support the specified version. - - - qpid.heartbeat - int - 120 (secs) - The heartbeat interval in seconds. Two consective misssed heartbeats will result in the connection timing out.This can also be set per connection using the Connection URL options. - - - - ignore_setclientID - boolean - false - If a client ID is specified in the connection URL it's used or else an ID is generated. If an ID is specified after it's been set Qpid will throw an exception. Setting this property to 'true' will disable that check and allow you to set a client ID of your choice later on. - - - -
- - - - Config Options For Session Behaviour - - - - Property Name - Type - Default Value - Description - - - - - qpid.session.command_limit - int - 65536 - Limits the # of unacked commands - - - - qpid.session.byte_limit - int - 1048576 - Limits the # of unacked commands in terms of bytes - - - - qpid.use_legacy_map_message - boolean - false - If set will use the old map message encoding. By default the Map messages are encoded using the 0-10 map encoding.This can also be set per connection using the Connection URL options. - - - - qpid.jms.daemon.dispatcher - boolean - false - Controls whether the Session dispatcher thread is a daemon thread or not. If this system property is set to true then the Session dispatcher threads will be created as daemon threads. This setting is introduced in version 0.16. - - - -
- - - Config Options For Consumer Behaviour - - - - Property Name - Type - Default Value - Description - - - - - max_prefetch - int - 500 - Maximum number of pre-fetched messages per consumer. This can also be defaulted for consumers created on a particular connection using the Connection URL options, or per destination (see the capacity option under link properties in addressing) - - - - qpid.session.max_ack_delay - long - 1000 (ms) - Timer interval to flush message acks in buffer when using AUTO_ACK and DUPS_OK. When using the above ack modes, message acks are batched and sent if one of the following conditions are met (which ever happens first). - - When the ack timer fires. - if un_acked_msg_count > max_prefetch/2. - - - The ack timer can be disabled by setting it to 0. - - - - - sync_ack - boolean - false - If set, each message will be acknowledged synchronously. When using AUTO_ACK mode, you need to set this to "true", in order to get the correct behaviour as described by the JMS spec.This is set to false by default for performance reasons, therefore by default AUTO_ACK behaves similar to DUPS_OK.This can also be set per connection using the Connection URL options. - - - -
- - - Config Options For Producer Behaviour - - - - Property Name - Type - Default Value - Description - - - - - sync_publish - string - "" (disabled) - If one of {persistent|all} is set then persistent messages or all messages will be sent synchronously.This can also be set per connection using the Connection URL options. - - - -
- - - Config Options For Threading - - - - Property Name - Type - Default Value - Description - - - - - qpid.thread_factory - string - org.apache.qpid.thread.DefaultThreadFactory - Specifies the thread factory to use.If using a real time JVM, you need to set the above property to org.apache.qpid.thread.RealtimeThreadFactory. - - - - qpid.rt_thread_priority - int - 20 - Specifies the priority (1-99) for Real time threads created by the real time thread factory. - - - -
- - - Config Options For I/O - - - - Property Name - Type - Default Value - Description - - - - - qpid.transport - string - org.apache.qpid.transport.network.io.IoNetworkTransport - The transport implementation to be used.A user could specify an alternative transport mechanism that implements the interface org.apache.qpid.transport.network.OutgoingNetworkTransport. - - - qpid.sync_op_timeout - long - 60000 - The length of time (in milliseconds) to wait for a synchronous operation to complete.For compatibility with older clients, the synonym amqj.default_syncwrite_timeout is supported. - - - qpid.tcp_nodelay - boolean - true - - Sets the TCP_NODELAY property of the underlying socket. The default was changed to true as of Qpid 0.14. - This can also be set per connection using the Connection URL options. - For compatibility with older clients, the synonym amqj.tcp_nodelay is supported. - - - - qpid.send_buffer_size - integer - 65535 - - Sets the SO_SNDBUF property of the underlying socket. Added in Qpid 0.16. - For compatibility with older clients, the synonym amqj.sendBufferSize is supported. - - - - qpid.receive_buffer_size - integer - 65535 - - Sets the SO_RCVBUF property of the underlying socket. Added in Qpid 0.16. - For compatibility with older clients, the synonym amqj.receiveBufferSize is supported. - - - - -
- - - Config Options For Security - - - - Property Name - Type - Default Value - Description - - - - - qpid.sasl_mechs - string - PLAIN - The SASL mechanism to be used. More than one could be specified as a comma separated list.We currently support the following mechanisms {PLAIN | GSSAPI | EXTERNAL}.This can also be set per connection using the Connection URL options. - - - - qpid.sasl_protocol - string - AMQP - When using GSSAPI as the SASL mechanism, sasl_protocol must be set to the principal for the qpidd broker, e.g. qpidd.This can also be set per connection using the Connection URL options. - - - - qpid.sasl_server_name - string - localhost - When using GSSAPI as the SASL mechanism, sasl_server must be set to the host for the SASL server, e.g. example.com.This can also be set per connection using the Connection URL options. - - - -
- - - Config Options For Security - Standard JVM properties needed when using GSSAPI as the SASL mechanism.<footnote><para>Please refer to the Java security documentation for a complete understanding of the above properties.</para></footnote> - - - - Property Name - Type - Default Value - Description - - - - - javax.security.auth.useSubjectCredsOnly - boolean - true - If set to 'false', forces the SASL GASSPI client to obtain the kerberos credentials explicitly instead of obtaining from the "subject" that owns the current thread. - - - - java.security.auth.login.config - string - - Specifies the jass configuration file.Ex-Djava.security.auth.login.config=myjas.conf -Here is the sample myjas.conf JASS configuration file: - - - -
- - - Config Options For Security - Using SSL for securing connections or using EXTERNAL as the SASL mechanism. - - - - Property Name - Type - Default Value - Description - - - - - qpid.ssl_timeout - long - 60000 - Timeout value used by the Java SSL engine when waiting on operations. - - - - qpid.ssl.KeyManagerFactory.algorithm - string - - - - The key manager factory algorithm name. If not set, defaults to the value returned from the Java runtime call KeyManagerFactory.getDefaultAlgorithm() - For compatibility with older clients, the synonym qpid.ssl.keyStoreCertType is supported. - - - - - qpid.ssl.TrustManagerFactory.algorithm - string - - - - The trust manager factory algorithm name. If not set, defaults to the value returned from the Java runtime call TrustManagerFactory.getDefaultAlgorithm() - For compatibility with older clients, the synonym qpid.ssl.trustStoreCertType is supported. - - - - -
- - - Config Options For Security - Standard JVM properties needed when Using SSL for securing connections or using EXTERNAL as the SASL mechanism.<footnote><para>Qpid allows you to have per connection key and trust stores if required. If specified per connection, the JVM arguments are ignored.</para></footnote> - - - - Property Name - Type - Default Value - Description - - - - - javax.net.ssl.keyStore - string - jvm default - Specifies the key store path.This can also be set per connection using the Connection URL options. - - - - javax.net.ssl.keyStorePassword - string - jvm default - Specifies the key store password.This can also be set per connection using the Connection URL options. - - - - javax.net.ssl.trustStore - string - jvm default - Specifies the trust store path.This can also be set per connection using the Connection URL options. - - - - javax.net.ssl.trustStorePassword - string - jvm default - Specifies the trust store password.This can also be set per connection using the Connection URL options. - - - -
-
+ + Config Options For Connection Behaviour + + + + Property Name + Type + Default Value + Description + + + + + qpid.amqp.version + string + 0-10 + Sets the AMQP version to be used - currently supports one of {0-8,0-9,0-91,0-10}.The client will begin negotiation at the specified version and only negotiate downwards if the Broker does not support the specified version. + + + qpid.heartbeat + int + 120 (secs) + The heartbeat interval in seconds. Two consective misssed heartbeats will result in the connection timing out.This can also be set per connection using the Connection URL options. + + + + ignore_setclientID + boolean + false + If a client ID is specified in the connection URL it's used or else an ID is generated. If an ID is specified after it's been set Qpid will throw an exception. Setting this property to 'true' will disable that check and allow you to set a client ID of your choice later on. + + + +
+ + + + Config Options For Session Behaviour + + + + Property Name + Type + Default Value + Description + + + + + qpid.session.command_limit + int + 65536 + Limits the # of unacked commands + + + + qpid.session.byte_limit + int + 1048576 + Limits the # of unacked commands in terms of bytes + + + + qpid.use_legacy_map_message + boolean + false + If set will use the old map message encoding. By default the Map messages are encoded using the 0-10 map encoding.This can also be set per connection using the Connection URL options. + + + + qpid.jms.daemon.dispatcher + boolean + false + Controls whether the Session dispatcher thread is a daemon thread or not. If this system property is set to true then the Session dispatcher threads will be created as daemon threads. This setting is introduced in version 0.16. + + + +
+ + + Config Options For Consumer Behaviour + + + + Property Name + Type + Default Value + Description + + + + + max_prefetch + int + 500 + Maximum number of pre-fetched messages per consumer. This can also be defaulted for consumers created on a particular connection using the Connection URL options, or per destination (see the capacity option under link properties in addressing) + + + + qpid.session.max_ack_delay + long + 1000 (ms) + Timer interval to flush message acks in buffer when using AUTO_ACK and DUPS_OK. When using the above ack modes, message acks are batched and sent if one of the following conditions are met (which ever happens first). + + When the ack timer fires. + if un_acked_msg_count > max_prefetch/2. + + + The ack timer can be disabled by setting it to 0. + + + + + sync_ack + boolean + false + If set, each message will be acknowledged synchronously. When using AUTO_ACK mode, you need to set this to "true", in order to get the correct behaviour as described by the JMS spec.This is set to false by default for performance reasons, therefore by default AUTO_ACK behaves similar to DUPS_OK.This can also be set per connection using the Connection URL options. + + + +
+ + + Config Options For Producer Behaviour + + + + Property Name + Type + Default Value + Description + + + + + sync_publish + string + "" (disabled) + If one of {persistent|all} is set then persistent messages or all messages will be sent synchronously.This can also be set per connection using the Connection URL options. + + + +
+ + + Config Options For Threading + + + + Property Name + Type + Default Value + Description + + + + + qpid.thread_factory + string + org.apache.qpid.thread.DefaultThreadFactory + Specifies the thread factory to use.If using a real time JVM, you need to set the above property to org.apache.qpid.thread.RealtimeThreadFactory. + + + + qpid.rt_thread_priority + int + 20 + Specifies the priority (1-99) for Real time threads created by the real time thread factory. + + + +
+ + + Config Options For I/O + + + + Property Name + Type + Default Value + Description + + + + + qpid.transport + string + org.apache.qpid.transport.network.io.IoNetworkTransport + The transport implementation to be used.A user could specify an alternative transport mechanism that implements the interface org.apache.qpid.transport.network.OutgoingNetworkTransport. + + + qpid.sync_op_timeout + long + 60000 + The length of time (in milliseconds) to wait for a synchronous operation to complete.For compatibility with older clients, the synonym amqj.default_syncwrite_timeout is supported. + + + qpid.tcp_nodelay + boolean + true + + Sets the TCP_NODELAY property of the underlying socket. The default was changed to true as of Qpid 0.14. + This can also be set per connection using the Connection URL options. + For compatibility with older clients, the synonym amqj.tcp_nodelay is supported. + + + + qpid.send_buffer_size + integer + 65535 + + Sets the SO_SNDBUF property of the underlying socket. Added in Qpid 0.16. + For compatibility with older clients, the synonym amqj.sendBufferSize is supported. + + + + qpid.receive_buffer_size + integer + 65535 + + Sets the SO_RCVBUF property of the underlying socket. Added in Qpid 0.16. + For compatibility with older clients, the synonym amqj.receiveBufferSize is supported. + + + + +
+ + + Config Options For Security + + + + Property Name + Type + Default Value + Description + + + + + qpid.sasl_mechs + string + PLAIN + The SASL mechanism to be used. More than one could be specified as a comma separated list.We currently support the following mechanisms {PLAIN | GSSAPI | EXTERNAL}.This can also be set per connection using the Connection URL options. + + + + qpid.sasl_protocol + string + AMQP + When using GSSAPI as the SASL mechanism, sasl_protocol must be set to the principal for the qpidd broker, e.g. qpidd.This can also be set per connection using the Connection URL options. + + + + qpid.sasl_server_name + string + localhost + When using GSSAPI as the SASL mechanism, sasl_server must be set to the host for the SASL server, e.g. example.com.This can also be set per connection using the Connection URL options. + + + +
+ + + Config Options For Security - Standard JVM properties needed when using GSSAPI as the SASL mechanism.<footnote><para>Please refer to the Java security documentation for a complete understanding of the above properties.</para></footnote> + + + + Property Name + Type + Default Value + Description + + + + + javax.security.auth.useSubjectCredsOnly + boolean + true + If set to 'false', forces the SASL GASSPI client to obtain the kerberos credentials explicitly instead of obtaining from the "subject" that owns the current thread. + + + + java.security.auth.login.config + string + + Specifies the jass configuration file.Ex-Djava.security.auth.login.config=myjas.conf + Here is the sample myjas.conf JASS configuration file: + + + +
+ + + Config Options For Security - Using SSL for securing connections or using EXTERNAL as the SASL mechanism. + + + + Property Name + Type + Default Value + Description + + + + + qpid.ssl_timeout + long + 60000 + Timeout value used by the Java SSL engine when waiting on operations. + + + + qpid.ssl.KeyManagerFactory.algorithm + string + - + + The key manager factory algorithm name. If not set, defaults to the value returned from the Java runtime call KeyManagerFactory.getDefaultAlgorithm() + For compatibility with older clients, the synonym qpid.ssl.keyStoreCertType is supported. + + + + + qpid.ssl.TrustManagerFactory.algorithm + string + - + + The trust manager factory algorithm name. If not set, defaults to the value returned from the Java runtime call TrustManagerFactory.getDefaultAlgorithm() + For compatibility with older clients, the synonym qpid.ssl.trustStoreCertType is supported. + + + + +
+ + + Config Options For Security - Standard JVM properties needed when Using SSL for securing connections or using EXTERNAL as the SASL mechanism.<footnote><para>Qpid allows you to have per connection key and trust stores if required. If specified per connection, the JVM arguments are ignored.</para></footnote> + + + + Property Name + Type + Default Value + Description + + + + + javax.net.ssl.keyStore + string + jvm default + Specifies the key store path.This can also be set per connection using the Connection URL options. + + + + javax.net.ssl.keyStorePassword + string + jvm default + Specifies the key store password.This can also be set per connection using the Connection URL options. + + + + javax.net.ssl.trustStore + string + jvm default + Specifies the trust store path.This can also be set per connection using the Connection URL options. + + + + javax.net.ssl.trustStorePassword + string + jvm default + Specifies the trust store password.This can also be set per connection using the Connection URL options. + + + +
+
@@ -3966,76 +3966,76 @@ log4j.appender.console.layout.ConversionPattern=%t %d %p [%c{4}] %m%n broker. - Traditional service model "Hello world!" example - Traditional service model "Hello world!" example + + }]]> - channelFactory = - new ChannelFactory(amqpBinding, clientEndpoint); - IHelloService clientProxy = channelFactory.CreateChannel(); - - clientProxy.SayHello("Greetings from WCF client"); - - // wait for service to process the greeting - while (HelloService.GreetingCount == 0) - { - Thread.Sleep(100); - } - channelFactory.Close(); - serviceHost.Close(); + AmqpBinding amqpBinding = new AmqpBinding(); + amqpBinding.BrokerHost = "localhost"; + amqpBinding.BrokerPort = 5672; + + ServiceHost serviceHost = new ServiceHost(typeof(HelloService)); + serviceHost.AddServiceEndpoint(typeof(IHelloService), + amqpBinding, "amqp:hello_service_node"); + serviceHost.Open(); + + // Send the service a test greeting + Uri amqpClientUri=new Uri("amqp:amq.direct?routingkey=hello_service_node"); + EndpointAddress clientEndpoint = new EndpointAddress(amqpClientUri); + ChannelFactory channelFactory = + new ChannelFactory(amqpBinding, clientEndpoint); + IHelloService clientProxy = channelFactory.CreateChannel(); + + clientProxy.SayHello("Greetings from WCF client"); + + // wait for service to process the greeting + while (HelloService.GreetingCount == 0) + { + Thread.Sleep(100); + } + channelFactory.Close(); + serviceHost.Close(); } catch (Exception e) { - Console.WriteLine("Exception: {0}", e); + Console.WriteLine("Exception: {0}", e); + } + } + } } - } - } -} ]]> @@ -4059,22 +4059,22 @@ namespace Apache.Qpid.Documentation.HelloService the Qpid C++ "Hello world!" example. - Binary "Hello world!" example using the channel model - Binary "Hello world!" example using the channel model + 0) { - broker = args[0]; + broker = args[0]; } if (args.Length > 1) { - port = int.Parse(args[1]); + port = int.Parse(args[1]); } if (args.Length > 2) { - target = args[2]; + target = args[2]; } if (args.Length > 3) { - source = args[3]; + source = args[3]; } AmqpBinaryBinding binding = new AmqpBinaryBinding(); @@ -4120,7 +4120,7 @@ namespace Apache.Qpid.Samples.Channel.HelloWorld XmlDictionaryReader reader = message.GetReaderAtBodyContents(); while (!reader.HasValue) { - reader.Read(); + reader.Read(); } byte[] binaryContent = reader.ReadContentAsBase64(); @@ -4130,24 +4130,24 @@ namespace Apache.Qpid.Samples.Channel.HelloWorld senderFactory.Close(); receiverFactory.Close(); - } - } + } + } - public class HelloWorldBinaryBodyWriter : BodyWriter - { - public HelloWorldBinaryBodyWriter() : base (true) {} + public class HelloWorldBinaryBodyWriter : BodyWriter + { + public HelloWorldBinaryBodyWriter() : base (true) {} - protected override void OnWriteBodyContents(XmlDictionaryWriter writer) - { + protected override void OnWriteBodyContents(XmlDictionaryWriter writer) + { byte[] binaryContent = Encoding.UTF8.GetBytes("Hello world!"); // wrap the content: writer.WriteStartElement("Binary"); writer.WriteBase64(binaryContent, 0, binaryContent.Length); - } - } -} -]]> + } + } + } + ]]> Bindings define ChannelFactories and ChannelListeners associated with diff --git a/qpid/doc/book/src/Starting-a-cluster.xml b/qpid/doc/book/src/Starting-a-cluster.xml deleted file mode 100644 index 036e571649..0000000000 --- a/qpid/doc/book/src/Starting-a-cluster.xml +++ /dev/null @@ -1,561 +0,0 @@ - - - -
- High Availability Messaging Clusters - - High Availability Messaging Clusters provide fault tolerance by ensuring that every broker in a cluster has the same queues, exchanges, messages, and bindings, and allowing a client to fail over to a new broker and continue without any loss of messages if the current broker fails or becomes unavailable. Because all brokers are automatically kept in a consistent state, clients can connect to and use any broker in a cluster. Any number of messaging brokers can be run as one cluster, and brokers can be added to or removed from a cluster while it is in use. - - - High Availability Messaging Clusters are implemented using using the OpenAIS Cluster Framework. - - - An OpenAIS daemon runs on every machine in the cluster, and these daemons communicate using multicast on a particular address. Every qpidd process in a cluster joins a named group that is automatically synchronized using OpenAIS Closed Process Groups (CPG) — the qpidd processes multicast events to the named group, and CPG ensures that each qpidd process receives all the events in the same sequence. All members get an identical sequence of events, so they can all update their state consistently. - - - Two messaging brokers are in the same cluster if - - - - They run on hosts in the same OpenAIS cluster; that is, OpenAIS is configured with the same mcastaddr, mcastport and bindnetaddr, and - - - - - - They use the same cluster name. - - - - - - - - - High Availability Clustering has a cost: in order to allow each broker in a cluster to continue the work of any other broker, a cluster must replicate state for all brokers in the cluster. Because of this, the brokers in a cluster should normally be on a LAN; there should be fast and reliable connections between brokers. Even on a LAN, using multiple brokers in a cluster is somewhat slower than using a single broker without clustering. This may be counter-intuitive for people who are used to clustering in the context of High Performance Computing or High Throughput Computing, where clustering increases performance or throughput. - - - - High Availability Messaging Clusters should be used together with Red Hat Clustering Services (RHCS); without RHCS, clusters are vulnerable to the "split-brain" condition, in which a network failure splits the cluster into two sub-clusters that cannot communicate with each other. See the documentation on the --cluster-cman option for details on running using RHCS with High Availability Messaging Clusters. See the CMAN Wiki for more detail on CMAN and split-brain conditions. Use the --cluster-cman option to enable RHCS when starting the broker. - -
- Starting a Broker in a Cluster - - Clustering is implemented using the cluster.so module, which is loaded by default when you start a broker. To run brokers in a cluster, make sure they all use the same OpenAIS mcastaddr, mcastport, and bindnetaddr. All brokers in a cluster must also have the same cluster name — specify the cluster name in qpidd.conf: - - -cluster-name="local_test_cluster" - - - On RHEL6, you must create the file /etc/corosync/uidgid.d/qpidd to tell Corosync the name of the user running the broker.By default, the user is qpidd: - - - -uidgid { - uid: qpidd - gid: qpidd -} - - - On RHEL5, the primary group for the process running qpidd must be the ais group. If you are running qpidd as a service, it is run as the qpidd user, which is already in the ais group. If you are running the broker from the command line, you must ensure that the primary group for the user running qpidd is ais. You can set the primary group using newgrp: - - -$ newgrp ais - - - You can then run the broker from the command line, specifying the cluster name as an option. - - -[jonathan@localhost]$ qpidd --cluster-name="local_test_cluster" - - - All brokers in a cluster must have identical configuration, with a few exceptions noted below. They must load the same set of plug-ins, and have matching configuration files and command line arguments. The should also have identical ACL files and SASL databases if these are used. If one broker uses persistence, all must use persistence — a mix of transient and persistent brokers is not allowed. Differences in configuration can cause brokers to exit the cluster. For instance, if different ACL settings allow a client to access a queue on broker A but not on broker B, then publishing to the queue will succeed on A and fail on B, so B will exit the cluster to prevent inconsistency. - - - The following settings can differ for brokers on a given cluster: - - - - - logging options - - - - - - cluster-url — if set, it will be different for each broker. - - - - - - port — brokers can listen on different ports. - - - - - - - The qpid log contains entries that record significant clustering events, e.g. when a broker becomes a member of a cluster, the membership of a cluster is changed, or an old journal is moved out of the way. For instance, the following message states that a broker has been added to a cluster as the first node: - - - -2009-07-09 18:13:41 info 127.0.0.1:1410(READY) member update: 127.0.0.1:1410(member) -2009-07-09 18:13:41 notice 127.0.0.1:1410(READY) first in cluster - - - - If you are using SELinux, the qpidd process and OpenAIS must have the same SELinux context, or else SELinux must be set to permissive mode. If both qpidd and OpenAIS are run as services, they have the same SELinux context. If both OpenAIS and qpidd are run as user processes, they have the same SELinux context. If one is run as a service, and the other is run as a user process, they have different SELinux contexts. - - - - - The following options are available for clustering: - - - Options for High Availability Messaging Cluster - - - - - - - Options for High Availability Messaging Cluster - - - - - - - - - --cluster-name NAME - - - Name of the Messaging Cluster to join. A Messaging Cluster consists of all brokers started with the same cluster-name and openais configuration. - - - - - - --cluster-size N - - - Wait for at least N initial members before completing cluster initialization and serving clients. Use this option in a persistent cluster so all brokers in a persistent cluster can exchange the status of their persistent store and do consistency checks before serving clients. - - - - - - --cluster-url URL - - - An AMQP URL containing the local address that the broker advertizes to clients for fail-over connections. This is different for each host. By default, all local addresses for the broker are advertized. You only need to set this if - - - - Your host has more than one active network interface, and - - - - - - You want to restrict client fail-over to a specific interface or interfaces. - - - - - - Each broker in the cluster is specified using the following form: - -url = ["amqp:"][ user ["/" password] "@" ] protocol_addr - ("," protocol_addr)* -protocol_addr = tcp_addr / rmda_addr / ssl_addr / ... -tcp_addr = ["tcp:"] host [":" port] -rdma_addr = "rdma:" host [":" port] -ssl_addr = "ssl:" host [":" port] - - In most cases, only one address is advertized, but more than one address can be specified in if the machine running the broker has more than one network interface card, and you want to allow clients to connect using multiple network interfaces. Use a comma delimiter (",") to separate brokers in the URL. Examples: - - - - amqp:tcp:192.168.1.103:5672 advertizes a single address to the broker for failover. - - - - - - amqp:tcp:192.168.1.103:5672,tcp:192.168.1.105:5672 advertizes two different addresses to the broker for failover, on two different network interfaces. - - - - - - - - - - - - --cluster-cman - - - - CMAN protects against the "split-brain" condition, in which a network failure splits the cluster into two sub-clusters that cannot communicate with each other. When "split-brain" occurs, each of the sub-clusters can access shared resources without knowledge of the other sub-cluster, resulting in corrupted cluster integrity. - - - To avoid "split-brain", CMAN uses the notion of a "quorum". If more than half the cluster nodes are active, the cluster has quorum and can act. If half (or fewer) nodes are active, the cluster does not have quorum, and all cluster activity is stopped. There are other ways to define the quorum for particular use cases (e.g. a cluster of only 2 members), see the CMAN Wiki -for more detail. - - - When enabled, the broker will wait until it belongs to a quorate cluster before accepting client connections. It continually monitors the quorum status and shuts down immediately if the node it runs on loses touch with the quorum. - - - - - - - - --cluster-username - - - SASL username for connections between brokers. - - - - - - --cluster-password - - - SASL password for connections between brokers. - - - - - - --cluster-mechanism - - - SASL authentication mechanism for connections between brokers - - - - - - - - -
- - If a broker is unable to establish a connection to another broker in the cluster, the log will contain SASL errors, e.g: - - -2009-aug-04 10:17:37 info SASL: Authentication failed: SASL(-13): user not found: Password verification failed - - - You can set the SASL user name and password used to connect to other brokers using the cluster-username and cluster-password properties when you start the broker. In most environment, it is easiest to create an account with the same user name and password on each broker in the cluster, and use these as the cluster-username and cluster-password. You can also set the SASL mode using cluster-mechanism. Remember that any mechanism you enable for broker-to-broker communication can also be used by a client, so do not enable cluster-mechanism=ANONYMOUS in a secure environment. - - - Once the cluster is running, run qpid-cluster to make sure that the brokers are running as one cluster. See the following section for details. - - - If the cluster is correctly configured, queues and messages are replicated to all brokers in the cluster, so an easy way to test the cluster is to run a program that routes messages to a queue on one broker, then connect to a different broker in the same cluster and read the messages to make sure they have been replicated. The drain and spout programs can be used for this test. - - -
- -
- qpid-cluster - - qpid-cluster is a command-line utility that allows you to view information on a cluster and its brokers, disconnect a client connection, shut down a broker in a cluster, or shut down the entire cluster. You can see the options using the --help option: - - -$ ./qpid-cluster --help - - -Usage: qpid-cluster [OPTIONS] [broker-addr] - - broker-addr is in the form: [username/password@] hostname | ip-address [:<port>] - ex: localhost, 10.1.1.7:10000, broker-host:10000, guest/guest@localhost - -Options: - -C [--all-connections] View client connections to all cluster members - -c [--connections] ID View client connections to specified member - -d [--del-connection] HOST:PORT - Disconnect a client connection - -s [--stop] ID Stop one member of the cluster by its ID - -k [--all-stop] Shut down the whole cluster - -f [--force] Suppress the 'are-you-sure?' prompt - -n [--numeric] Don't resolve names - - - Let's connect to a cluster and display basic information about the cluser and its brokers. When you connect to the cluster using qpid-tool, you can use the host and port for any broker in the cluster. For instance, if a broker in the cluster is running on localhost on port 6664, you can start qpid-tool like this: - - - -$ qpid-cluster localhost:6664 - - - Here is the output: - - - - Cluster Name: local_test_cluster -Cluster Status: ACTIVE - Cluster Size: 3 - Members: ID=127.0.0.1:13143 URL=amqp:tcp:192.168.1.101:6664,tcp:192.168.122.1:6664,tcp:10.16.10.62:6664 - : ID=127.0.0.1:13167 URL=amqp:tcp:192.168.1.101:6665,tcp:192.168.122.1:6665,tcp:10.16.10.62:6665 - : ID=127.0.0.1:13192 URL=amqp:tcp:192.168.1.101:6666,tcp:192.168.122.1:6666,tcp:10.16.10.62:6666 - - - The ID for each broker in cluster is given on the left. For instance, the ID for the first broker in the cluster is 127.0.0.1:13143. The URL in the output is the broker's advertized address. Let's use the ID to shut the broker down using the --stop command: - - -$ ./qpid-cluster localhost:6664 --stop 127.0.0.1:13143 - - -
- -
- Failover in Clients - - If a client is connected to a broker, the connection fails if the broker crashes or is killed. If heartbeat is enabled for the connection, a connection also fails if the broker hangs, the machine the broker is running on fails, or the network connection to the broker is lost — the connection fails no later than twice the heartbeat interval. - - - When a client's connection to a broker fails, any sent messages that have been acknowledged to the sender will have been replicated to all brokers in the cluster, any received messages that have not yet been acknowledged by the receiving client requeued to all brokers, and the client API notifies the application of the failure by throwing an exception. - - - Clients can be configured to automatically reconnect to another broker when it receives such an exception. Any messages that have been sent by the client, but not yet acknowledged as delivered, are resent. Any messages that have been read by the client, but not acknowledged, are delivered to the client. - - - TCP is slow to detect connection failures. A client can configure a connection to use a heartbeat to detect connection failure, and can specify a time interval for the heartbeat. If heartbeats are in use, failures will be detected no later than twice the heartbeat interval. The Java JMS client enables hearbeat by default. See the sections on Failover in Java JMS Clients and Failover in C++ Clients for the code to enable heartbeat. - -
- Failover in Java JMS Clients - - In Java JMS clients, client failover is handled automatically if it is enabled in the connection. Any messages that have been sent by the client, but not yet acknowledged as delivered, are resent. Any messages that have been read by the client, but not acknowledged, are sent to the client. - - - You can configure a connection to use failover using the failover property: - - - -connectionfactory.qpidConnectionfactory = amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:5672'&failover='failover_exchange' - - - This property can take three values: - - - Failover Modes - - failover_exchange - - - If the connection fails, fail over to any other broker in the cluster. - - - - - - - roundrobin - - - If the connection fails, fail over to one of the brokers specified in the brokerlist. - - - - - - - singlebroker - - - Failover is not supported; the connection is to a single broker only. - - - - - - - - - In a Connection URL, heartbeat is set using the idle_timeout property, which is an integer corresponding to the heartbeat period in seconds. For instance, the following line from a JNDI properties file sets the heartbeat time out to 3 seconds: - - - -connectionfactory.qpidConnectionfactory = amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:5672',idle_timeout=3 - - -
- -
- Failover and the Qpid Messaging API - - The Qpid Messaging API also supports automatic reconnection in the event a connection fails. . Senders can also be configured to replay any in-doubt messages (i.e. messages whice were sent but not acknowleged by the broker. See "Connection Options" and "Sender Capacity and Replay" in Programming in Apache Qpid for details. - - - In C++ and python clients, heartbeats are disabled by default. You can enable them by specifying a heartbeat interval (in seconds) for the connection via the 'heartbeat' option. - - - See "Cluster Failover" in Programming in Apache Qpid for details on how to keep the client aware of cluster membership. - - -
- - -
- -
- Error handling in Clusters - - If a broker crashes or is killed, or a broker machine failure, broker connection failure, or a broker hang is detected, the other brokers in the cluster are notified that it is no longer a member of the cluster. If a new broker is joined to the cluster, it synchronizes with an active broker to obtain the current cluster state; if this synchronization fails, the new broker exit the cluster and aborts. - - - If a broker becomes extremely busy and stops responding, it stops accepting incoming work. All other brokers continue processing, and the non-responsive node caches all AIS traffic. When it resumes, the broker completes processes all cached AIS events, then accepts further incoming work. - - - Broker hangs are only detected if the watchdog plugin is loaded and the --watchdog-interval option is set. The watchdog plug-in kills the qpidd broker process if it becomes stuck for longer than the watchdog interval. In some cases, e.g. certain phases of error resolution, it is possible for a stuck process to hang other cluster members that are waiting for it to send a message. Using the watchdog, the stuck process is terminated and removed from the cluster, allowing other members to continue and clients of the stuck process to fail over to other members. - - - Redundancy can also be achieved directly in the AIS network by specifying more than one network interface in the AIS configuration file. This causes Totem to use a redundant ring protocol, which makes failure of a single network transparent. - - - Redundancy can be achieved at the operating system level by using NIC bonding, which combines multiple network ports into a single group, effectively aggregating the bandwidth of multiple interfaces into a single connection. This provides both network load balancing and fault tolerance. - - - If any broker encounters an error, the brokers compare notes to see if they all received the same error. If not, the broker removes itself from the cluster and shuts itself down to ensure that all brokers in the cluster have consistent state. For instance, a broker may run out of disk space; if this happens, the broker shuts itself down. Examining the broker's log can help determine the error and suggest ways to prevent it from occuring in the future. - - -
- -
- Persistence in High Availability Message Clusters - - Persistence and clustering are two different ways to provide reliability. Most systems that use a cluster do not enable persistence, but you can do so if you want to ensure that messages are not lost even if the last broker in a cluster fails. A cluster must have all transient or all persistent members, mixed clusters are not allowed. Each broker in a persistent cluster has it's own independent replica of the cluster's state it its store. - -
- Clean and Dirty Stores - - When a broker is an active member of a cluster, its store is marked "dirty" because it may be out of date compared to other brokers in the cluster. If a broker leaves a running cluster because it is stopped, it crashes or the host crashes, its store continues to be marked "dirty". - - - If the cluster is reduced to a single broker, its store is marked "clean" since it is the only broker making updates. If the cluster is shut down with the command qpid-cluster -k then all the stores are marked clean. - - - When a cluster is initially formed, brokers with clean stores read from their stores. Brokers with dirty stores, or brokers that join after the cluster is running, discard their old stores and initialize a new store with an update from one of the running brokers. The --truncate option can be used to force a broker to discard all existing stores even if they are clean. (A dirty store is discarded regardless.) - - - Discarded stores are copied to a back up directory. The active store is in <data-dir>/rhm. Back-up stores are in <data-dir>/_cluster.bak.<nnnn>/rhm, where <nnnn> is a 4 digit number. A higher number means a more recent backup. - - -
- -
- Starting a persistent cluster - - When starting a persistent cluster broker, set the cluster-size option to the number of brokers in the cluster. This allows the brokers to wait until the entire cluster is running so that they can synchronize their stored state. - - - The cluster can start if: - - - - - - all members have empty stores, or - - - - - - at least one member has a clean store - - - - - - - - - All members of the new cluster will be initialized with the state from a clean store. - - -
- -
- Stopping a persistent cluster - - To cleanly shut down a persistent cluster use the command qpid-cluster -k. This causes all brokers to synchronize their state and mark their stores as "clean" so they can be used when the cluster restarts. - - -
- -
- Starting a persistent cluster with no clean store - - If the cluster has previously had a total failure and there are no clean stores then the brokers will fail to start with the log message Cannot recover, no clean store. If this happens you can start the cluster by marking one of the stores "clean" as follows: - - - - - Move the latest store backup into place in the brokers data-directory. The backups end in a 4 digit number, the latest backup is the highest number. - - - - cd <data-dir> - mv rhm rhm.bak - cp -a _cluster.bak.<nnnn>/rhm . - - - - - - Mark the store as clean: -qpid-cluster-store -c <data-dir> - - - - - - - - - Now you can start the cluster, all members will be initialized from the store you marked as clean. - - -
- -
- Isolated failures in a persistent cluster - - A broker in a persistent cluster may encounter errors that other brokers in the cluster do not; if this happens, the broker shuts itself down to avoid making the cluster state inconsistent. For example a disk failure on one node will result in that node shutting down. Running out of storage capacity can also cause a node to shut down because because the brokers may not run out of storage at exactly the same point, even if they have similar storage configuration. To avoid unnecessary broker shutdowns, make sure the queue policy size of each durable queue is less than the capacity of the journal for the queue. - - -
- - -
- - -
diff --git a/qpid/doc/book/src/schemas.xml b/qpid/doc/book/src/schemas.xml index d0bec81aed..6102e65f07 100644 --- a/qpid/doc/book/src/schemas.xml +++ b/qpid/doc/book/src/schemas.xml @@ -1,23 +1,23 @@ @@ -26,76 +26,77 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.1