From 5e23db780c51e80da6f06ffee3ee53ff12c6851c Mon Sep 17 00:00:00 2001 From: Alex Rudyy Date: Fri, 7 Jun 2013 22:42:51 +0000 Subject: QPID-4914: Document how to bind queues to exchanges git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1490857 13f79535-47bb-0310-9956-ffa450edef68 --- .../java-broker/Java-Broker-Queues-OtherTypes.xml | 72 ++++++++++++++++++++++ .../Java-Broker-Virtual-Hosts-Configuration.xml | 25 ++++++++ 2 files changed, 97 insertions(+) (limited to 'qpid') diff --git a/qpid/doc/book/src/java-broker/Java-Broker-Queues-OtherTypes.xml b/qpid/doc/book/src/java-broker/Java-Broker-Queues-OtherTypes.xml index 674dabec54..9d94523c06 100644 --- a/qpid/doc/book/src/java-broker/Java-Broker-Queues-OtherTypes.xml +++ b/qpid/doc/book/src/java-broker/Java-Broker-Queues-OtherTypes.xml @@ -188,6 +188,78 @@ managedBroker.createNewQueue("myqueue", null, true, arguments);]]> +
+ Binding queues to exchanges + Queues can be bound to the broker exchanges in the virtualhost + configuration file or programmtically from a client using AMQP bind API (using + an extension to JMS), using JMX API, using REST interfaces or Web Management Console. + A queue can be bound to different exchanges at the same time. + Also, a queue can be bound to the same exchange multiple times. + Differenent binding keys can be used to bind a queue to the same topic or direct exchanges. + Binding attributes can be specified on binding creation to allow filtering of messages accepted by the queue using a selector expression + or/and specifying whether messages published by its own connection should be delivered to it. +
+ Using Web Management Console + A queue can be bound to an exchange by clicking on "Add Binding" button on a Queue tab or an Exchange tab. +
+
+ Using JMX or AMQP + The following example illustrates the creation of queue binding to topic exchange with JMS client. + + Binding a queue using JMS + session = (AMQSession)connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + +... + +AMQShortString queueName = new AMQShortString("testQueue"); +AMQShortString routingKey = new AMQShortString("testRoutingKey"); +AMQDestination destination = (AMQDestination) session.createQueue(queueName.asString()); + +... + +// binding arguments +Map arguments = new HashMap(); +arguments.put("x-filter-jms-selector", "application='app1'"); + +// create binding +session.bindQueue(queueName, routingKey, FieldTable.convertToFieldTable(arguments), + new AMQShortString("amq.topic"), destination);]]> + + The following example illustrates the creation of queue binding to topic exchange with JMX + interface using the ManagedExchange interface. + + Binding a queue using JMX + environment = new HashMap(); +environment.put(JMXConnector.CREDENTIALS, new String[] {"admin","password"}); + +// Connect to service +JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:8999/jmxrmi"); +JMXConnector jmxConnector = JMXConnectorFactory.connect(url, environment); +MBeanServerConnection mbsc = jmxConnector.getMBeanServerConnection(); + +// Object name for topic Exchange MBean for virtualhost 'default' +ObjectName objectName = new ObjectName("org.apache.qpid:type=VirtualHost.Exchange," + + "VirtualHost=\"default\",name=\"amq.topic\",ExchangeType=topic"); + +// Get the ManagedExchange object +ManagedExchange topicExchange = JMX.newMBeanProxy(mbsc, objectName, ManagedExchange.class);; + +// Create the binding arguments +Map arguments = new HashMap(); +arguments.put("x-filter-jms-selector", "application='app1'"); + +// create binding +topicExchange.createNewBinding("queue", "testBindingKey", arguments);]]> + +
+
+ Using configuration + How to bind queues in the Virtual Host configuration file is shown in . +
+
+
Messaging Grouping diff --git a/qpid/doc/book/src/java-broker/Java-Broker-Virtual-Hosts-Configuration.xml b/qpid/doc/book/src/java-broker/Java-Broker-Virtual-Hosts-Configuration.xml index 0d1e3f8f5c..3a83fb324d 100644 --- a/qpid/doc/book/src/java-broker/Java-Broker-Virtual-Hosts-Configuration.xml +++ b/qpid/doc/book/src/java-broker/Java-Broker-Virtual-Hosts-Configuration.xml @@ -338,6 +338,31 @@ </section> </section> + <section role="h2" id="Java-Broker-Virtual-Host-Binding-Queue"> + <title>Queue Binding + Element routingKey is used to specify a binding key. + Also, elements bindingArgument is used to specify the binding arguments. + They have to be contained in the element having the same name as a binding key. + The following example demonstrates how to bind queue testQueue to a topic exchange + using routing key testRoutingKey and binding arguments for message selector and no local. + + Queue Binding Example + + testQueue + + amq.topic + testRoutingKey + + x-filter-jms-selector=application='app1' + x-qpid-no-local= + + +]]> + + + Additionally, the queue is bound to the exchange with a binding key equal to the queue name. +
+
Configuring of Producer Flow Control Flow control capacity and flow resume capacity are required to set on a queue or virtual host to enable Producer flow control. -- cgit v1.2.1