summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMarc Falzon <marc@falzon.me>2013-08-16 21:59:03 +0200
committerAlan Antonuk <alan.antonuk@gmail.com>2013-08-21 16:32:52 -0700
commit1d9c5291fff0a66fac0082dae42e382d94b3c96f (patch)
treecbffa11a7459fb4e84c4bd117e2cadfce1dea037 /tools
parenta5749657ee7571788d74702969f69cd37616c6dd (diff)
downloadrabbitmq-c-github-ask-1d9c5291fff0a66fac0082dae42e382d94b3c96f.tar.gz
Non-exclusive queue declaration in amqp-consume.
Declare non-exclusive queue by default, which allows task queue round-robin publishing when binding to a "direct" typed exchange with a routing key matching the publisher's one and the queue name. The "-d" option is replaced with a "-x" option to explicitly declare an exclusive queue if needed.
Diffstat (limited to 'tools')
-rw-r--r--tools/consume.c16
-rw-r--r--tools/doc/amqp-consume.xml15
2 files changed, 26 insertions, 5 deletions
diff --git a/tools/consume.c b/tools/consume.c
index 9075302..5b7777e 100644
--- a/tools/consume.c
+++ b/tools/consume.c
@@ -75,7 +75,8 @@ static char *stringify_bytes(amqp_bytes_t bytes)
static amqp_bytes_t setup_queue(amqp_connection_state_t conn,
char *queue, char *exchange,
- char *routing_key, int declare)
+ char *routing_key, int declare,
+ int exclusive)
{
amqp_bytes_t queue_bytes = cstring_bytes(queue);
@@ -92,10 +93,10 @@ static amqp_bytes_t setup_queue(amqp_connection_state_t conn,
exit(1);
}
- if (!queue || exchange || declare) {
+ if (!queue || exchange || declare || exclusive) {
/* Declare the queue as auto-delete. */
amqp_queue_declare_ok_t *res = amqp_queue_declare(conn, 1,
- queue_bytes, 0, 0, 1, 1,
+ queue_bytes, 0, 0, exclusive, 1,
amqp_empty_table);
if (!res) {
die_rpc(amqp_get_rpc_reply(conn), "queue.declare");
@@ -193,6 +194,7 @@ int main(int argc, const char **argv)
char *exchange = NULL;
char *routing_key = NULL;
int declare = 0;
+ int exclusive = 0;
int no_ack = 0;
int count = -1;
amqp_bytes_t queue_bytes;
@@ -213,7 +215,11 @@ int main(int argc, const char **argv)
},
{
"declare", 'd', POPT_ARG_NONE, &declare, 0,
- "declare an exclusive queue", NULL
+ "declare an exclusive queue (deprecated, use --exclusive instead)", NULL
+ },
+ {
+ "exclusive", 'x', POPT_ARG_NONE, &exclusive, 0,
+ "declare the queue as exclusive", NULL
},
{
"no-ack", 'A', POPT_ARG_NONE, &no_ack, 0,
@@ -239,7 +245,7 @@ int main(int argc, const char **argv)
}
conn = make_connection();
- queue_bytes = setup_queue(conn, queue, exchange, routing_key, declare);
+ queue_bytes = setup_queue(conn, queue, exchange, routing_key, declare, exclusive);
do_consume(conn, queue_bytes, no_ack, count, cmd_argv);
close_connection(conn);
return 0;
diff --git a/tools/doc/amqp-consume.xml b/tools/doc/amqp-consume.xml
index b5f40d7..f6f51ba 100644
--- a/tools/doc/amqp-consume.xml
+++ b/tools/doc/amqp-consume.xml
@@ -119,6 +119,21 @@
<option>--queue</option> option, but no
binding to an exchange is requested with the
<option>--exchange</option> option.
+ Note: this option is deprecated and may be
+ removed in a future version, use the
+ <option>--exclusive</option> option to
+ explicitly declare an exclusive queue.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-x</option></term>
+ <term><option>--exclusive</option></term>
+ <listitem>
+ <para>
+ Declared queues are non-exclusive by default,
+ this option forces declaration of exclusive
+ queues.
</para>
</listitem>
</varlistentry>