From 1d9c5291fff0a66fac0082dae42e382d94b3c96f Mon Sep 17 00:00:00 2001 From: Marc Falzon Date: Fri, 16 Aug 2013 21:59:03 +0200 Subject: 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. --- tools/consume.c | 16 +++++++++++----- tools/doc/amqp-consume.xml | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) (limited to 'tools') 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, but no binding to an exchange is requested with the option. + Note: this option is deprecated and may be + removed in a future version, use the + option to + explicitly declare an exclusive queue. + + + + + + + + + Declared queues are non-exclusive by default, + this option forces declaration of exclusive + queues. -- cgit v1.2.1