diff options
author | Alexandru Scvortov <alexandru@rabbitmq.com> | 2010-08-17 09:29:27 +0100 |
---|---|---|
committer | Alexandru Scvortov <alexandru@rabbitmq.com> | 2010-08-17 09:29:27 +0100 |
commit | d7f05275eefdf4a81e7b420d0b5374be011aad7c (patch) | |
tree | 4461fa902b99cd75ebebcdd1e4c49366fe5cf996 | |
parent | 10cefe79af380e0402907683a60f93ab9850fdca (diff) | |
parent | 16d14c5473908ac7e61a88a543c64385469cd0ee (diff) | |
download | rabbitmq-c-github-ask-d7f05275eefdf4a81e7b420d0b5374be011aad7c.tar.gz |
merge default into bug22951
-rwxr-xr-x | etc/install-mingw.sh | 25 | ||||
-rw-r--r-- | librabbitmq/Makefile.am | 2 | ||||
-rw-r--r-- | tools/Makefile.am | 2 | ||||
-rw-r--r-- | tools/consume.c | 90 | ||||
-rw-r--r-- | tools/doc/consume.xml | 58 |
5 files changed, 81 insertions, 96 deletions
diff --git a/etc/install-mingw.sh b/etc/install-mingw.sh index 891c6fe..af70576 100755 --- a/etc/install-mingw.sh +++ b/etc/install-mingw.sh @@ -23,7 +23,7 @@ done <<EOF MinGW/mpc/mpc-0.8.1-1/libmpc-0.8.1-1-mingw32-dll-2.tar.lzma MinGW/BaseSystem/GCC/Version4/gcc-4.5.0-1/gcc-core-4.5.0-1-mingw32-bin.tar.lzma MinGW/BaseSystem/GCC/Version4/gcc-4.5.0-1/libgcc-4.5.0-1-mingw32-dll-1.tar.lzma -MSYS/BaseSystem/msys-1.0.14-1/msysCORE-1.0.14-1-msys-1.0.14-bin.tar.lzma +MSYS/BaseSystem/msys-core/msys-1.0.14-1/msysCORE-1.0.14-1-msys-1.0.14-bin.tar.lzma MinGW/BaseSystem/GNU-Binutils/binutils-2.20.1/binutils-2.20.1-2-mingw32-bin.tar.gz MinGW/BaseSystem/RuntimeLibrary/MinGW-RT/mingwrt-3.18/mingwrt-3.18-mingw32-dll.tar.gz MinGW/BaseSystem/RuntimeLibrary/MinGW-RT/mingwrt-3.18/mingwrt-3.18-mingw32-dev.tar.gz @@ -33,15 +33,15 @@ MinGW/gmp/gmp-5.0.1-1/libgmpxx-5.0.1-1-mingw32-dll-4.tar.lzma MinGW/gmp/gmp-5.0.1-1/libgmp-5.0.1-1-mingw32-dll-10.tar.lzma MinGW/BaseSystem/RuntimeLibrary/Win32-API/w32api-3.14/w32api-3.14-mingw32-dev.tar.gz MSYS/make/make-3.81-2/make-3.81-2-msys-1.0.11-bin.tar.lzma -MSYS/bash/bash-3.1.17-2/bash-3.1.17-2-msys-1.0.11-bin.tar.lzma -MSYS/coreutils/coreutils-5.97-2/coreutils-5.97-2-msys-1.0.11-bin.tar.lzma +MSYS/BaseSystem/bash/bash-3.1.17-2/bash-3.1.17-2-msys-1.0.11-bin.tar.lzma +MSYS/BaseSystem/coreutils/coreutils-5.97-2/coreutils-5.97-2-msys-1.0.11-bin.tar.lzma MinGW/popt/popt-1.15-1/libpopt-1.15-1-mingw32-dll-0.tar.lzma MinGW/popt/popt-1.15-1/libpopt-1.15-1-mingw32-dev.tar.lzma -MSYS/diffutils/diffutils-2.8.7.20071206cvs-2/diffutils-2.8.7.20071206cvs-2-msys-1.0.11-bin.tar.lzma -MSYS/gawk/gawk-3.1.7-1/gawk-3.1.7-1-msys-1.0.11-bin.tar.lzma -MSYS/grep/grep-2.5.4-1/grep-2.5.4-1-msys-1.0.11-bin.tar.lzma -MSYS/sed/sed-4.2.1-1/sed-4.2.1-1-msys-1.0.11-bin.tar.lzma -MSYS/libtool/libtool-2.2.7a-1/libtool-2.2.7a-1-msys-1.0.11-bin.tar.lzma +MSYS/BaseSystem/diffutils/diffutils-2.8.7.20071206cvs-2/diffutils-2.8.7.20071206cvs-2-msys-1.0.11-bin.tar.lzma +MSYS/BaseSystem/gawk/gawk-3.1.7-1/gawk-3.1.7-1-msys-1.0.11-bin.tar.lzma +MSYS/BaseSystem/grep/grep-2.5.4-1/grep-2.5.4-1-msys-1.0.11-bin.tar.lzma +MSYS/BaseSystem/sed/sed-4.2.1-1/sed-4.2.1-1-msys-1.0.11-bin.tar.lzma +MSYS/libtool/libtool-2.2.7a-2/libtool-2.2.7a-2-msys-1.0.13-bin.tar.lzma MinGW/gettext/gettext-0.17-1/libintl-0.17-1-mingw32-dll-8.tar.lzma MinGW/gettext/gettext-0.17-1/gettext-0.17-1-mingw32-dev.tar.lzma MinGW/libiconv/libiconv-1.13.1-1/libiconv-1.13.1-1-mingw32-dll-2.tar.lzma @@ -50,11 +50,10 @@ MinGW/libiconv/libiconv-1.13.1-1/libcharset-1.13.1-1-mingw32-dll-1.tar.lzma MSYS/autoconf/autoconf-2.65-1/autoconf-2.65-1-msys-1.0.13-bin.tar.lzma MSYS/automake/automake-1.11.1-1/automake-1.11.1-1-msys-1.0.13-bin.tar.lzma MSYS/m4/m4-1.4.14-1/m4-1.4.14-1-msys-1.0.13-bin.tar.lzma -MSYS/libtool/libtool-2.2.7a-2/libtool-2.2.7a-2-msys-1.0.13-bin.tar.lzma -MSYS/tar/tar-1.23-1/tar-1.23-1-msys-1.0.13-bin.tar.lzma -MSYS/regex/regex-1.20090805-2/libregex-1.20090805-2-msys-1.0.13-dll-1.tar.lzma -MSYS/libiconv/libiconv-1.13.1-2/libiconv-1.13.1-2-msys-1.0.13-dll-2.tar.lzma -MSYS/gettext/gettext-0.17-2/libintl-0.17-2-msys-dll-8.tar.lzma +MSYS/BaseSystem/tar/tar-1.23-1/tar-1.23-1-msys-1.0.13-bin.tar.lzma +MSYS/BaseSystem/regex/regex-1.20090805-2/libregex-1.20090805-2-msys-1.0.13-dll-1.tar.lzma +MSYS/BaseSystem/libiconv/libiconv-1.13.1-2/libiconv-1.13.1-2-msys-1.0.13-dll-2.tar.lzma +MSYS/BaseSystem/gettext/gettext-0.17-2/libintl-0.17-2-msys-dll-8.tar.lzma MSYS/perl/perl-5.6.1_2-2/perl-5.6.1_2-2-msys-1.0.13-bin.tar.lzma MSYS/crypt/crypt-1.1_1-3/libcrypt-1.1_1-3-msys-1.0.13-dll-0.tar.lzma EOF diff --git a/librabbitmq/Makefile.am b/librabbitmq/Makefile.am index 35680d0..82b9f30 100644 --- a/librabbitmq/Makefile.am +++ b/librabbitmq/Makefile.am @@ -1,6 +1,6 @@ lib_LTLIBRARIES = librabbitmq.la -AM_CFLAGS = -I$(PLATFORM_DIR) +AM_CFLAGS = -I$(srcdir)/$(PLATFORM_DIR) librabbitmq_la_SOURCES = amqp_mem.c amqp_table.c amqp_connection.c amqp_socket.c amqp_debug.c amqp_api.c $(PLATFORM_DIR)/socket.c librabbitmq_la_LDFLAGS = -no-undefined librabbitmq_la_LIBADD = $(EXTRA_LIBS) diff --git a/tools/Makefile.am b/tools/Makefile.am index ef7a9bc..ccd36ca 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -2,7 +2,7 @@ SUBDIRS=doc bin_PROGRAMS = amqp-publish amqp-get amqp-consume amqp-declare-queue amqp-delete-queue -AM_CFLAGS = -I$(top_srcdir)/librabbitmq -I$(PLATFORM_DIR) +AM_CFLAGS = -I$(top_srcdir)/librabbitmq -I$(srcdir)/$(PLATFORM_DIR) AM_LDFLAGS = $(top_builddir)/librabbitmq/librabbitmq.la LDADD=$(LIBPOPT) diff --git a/tools/consume.c b/tools/consume.c index 146b0a7..34037d9 100644 --- a/tools/consume.c +++ b/tools/consume.c @@ -84,61 +84,45 @@ static char *stringify_bytes(amqp_bytes_t bytes) static amqp_bytes_t setup_queue(amqp_connection_state_t conn, char *queue, char *exchange, - char *exchange_type, char *routing_key) + char *routing_key, int declare) { - amqp_bytes_t queue_bytes; - amqp_queue_declare_ok_t *res; + amqp_bytes_t queue_bytes = cstring_bytes(queue); /* if an exchange name wasn't provided, check that we don't have options that require it. */ - if (!exchange) { - char *opt = NULL; - if (routing_key) - opt = "--routing-key"; - else if (exchange_type) - opt = "--exchange-type"; - - if (opt) { - fprintf(stderr, - "%s option requires an exchange name to be " - "provided with --exchange\n", opt); - exit(1); - } + if (!exchange && routing_key) { + fprintf(stderr, "--routing-key option requires an exchange" + " name to be provided with --exchange\n"); + exit(1); } - /* Declare the queue as auto-delete. If the queue already - exists, this won't have any effect. */ - queue_bytes = cstring_bytes(queue); - res = amqp_queue_declare(conn, 1, queue_bytes, 0, 0, 0, 1, - AMQP_EMPTY_TABLE); - if (!res) - die_rpc(amqp_get_rpc_reply(conn), "queue.declare"); - - if (!queue) { - /* the server should have provided a queue name */ - char *sq; - queue_bytes = amqp_bytes_malloc_dup(res->queue); - sq = stringify_bytes(queue_bytes); - fprintf(stderr, "Server provided queue name: %s\n", sq); - free(sq); - } + if (!queue || exchange || declare) { + /* Declare the queue as auto-delete. */ + amqp_queue_declare_ok_t *res = amqp_queue_declare(conn, 1, + queue_bytes, 0, 0, 1, 1, + AMQP_EMPTY_TABLE); + if (!res) + die_rpc(amqp_get_rpc_reply(conn), "queue.declare"); + + if (!queue) { + /* the server should have provided a queue name */ + char *sq; + queue_bytes = amqp_bytes_malloc_dup(res->queue); + sq = stringify_bytes(queue_bytes); + fprintf(stderr, "Server provided queue name: %s\n", + sq); + free(sq); + } - /* Bind to an exchange if requested */ - if (exchange) { - amqp_bytes_t eb = amqp_cstring_bytes(exchange); - - if (exchange_type) { - /* we should create the exchange */ - if (!amqp_exchange_declare(conn, 1, eb, - amqp_cstring_bytes(exchange_type), - 0, 0, AMQP_EMPTY_TABLE)) - die_rpc(amqp_get_rpc_reply(conn), "exchange.declare"); + /* Bind to an exchange if requested */ + if (exchange) { + amqp_bytes_t eb = amqp_cstring_bytes(exchange); + if (!amqp_queue_bind(conn, 1, queue_bytes, eb, + cstring_bytes(routing_key), + AMQP_EMPTY_TABLE)) + die_rpc(amqp_get_rpc_reply(conn), + "queue.bind"); } - - if (!amqp_queue_bind(conn, 1, queue_bytes, eb, - cstring_bytes(routing_key), - AMQP_EMPTY_TABLE)) - die_rpc(amqp_get_rpc_reply(conn), "queue.bind"); } return queue_bytes; @@ -181,13 +165,13 @@ static void do_consume(amqp_connection_state_t conn, amqp_bytes_t queue, int main(int argc, const char **argv) { poptContext opts; - int no_ack; amqp_connection_state_t conn; const char * const *cmd_argv; char *queue = NULL; char *exchange = NULL; - char *exchange_type = NULL; char *routing_key = NULL; + int declare = 0; + int no_ack = 0; amqp_bytes_t queue_bytes; struct poptOption options[] = { @@ -196,11 +180,10 @@ int main(int argc, const char **argv) "the queue to consume from", "queue"}, {"exchange", 'e', POPT_ARG_STRING, &exchange, 0, "bind the queue to this exchange", "exchange"}, - {"exchange-type", 't', POPT_ARG_STRING, &exchange_type, 0, - "create auto-delete exchange of this type for binding", - "type"}, {"routing-key", 'r', POPT_ARG_STRING, &routing_key, 0, "the routing key to bind with", "routing key"}, + {"declare", 'd', POPT_ARG_NONE, &declare, 0, + "declare an exclusive queue", NULL}, {"no-ack", 'A', POPT_ARG_NONE, &no_ack, 0, "consume in no-ack mode", NULL}, POPT_AUTOHELP @@ -218,8 +201,7 @@ int main(int argc, const char **argv) } conn = make_connection(); - queue_bytes = setup_queue(conn, queue, exchange, exchange_type, - routing_key); + queue_bytes = setup_queue(conn, queue, exchange, routing_key, declare); do_consume(conn, queue_bytes, no_ack, cmd_argv); close_connection(conn); return 0; diff --git a/tools/doc/consume.xml b/tools/doc/consume.xml index 448ade6..16d61ad 100644 --- a/tools/doc/consume.xml +++ b/tools/doc/consume.xml @@ -50,8 +50,7 @@ <para> <command>amqp-consume</command> can consume from an existing queue, or it can create a new queue. It can - optionally bind the queue to an existing exchange, or to a - newly created exchange. + optionally bind the queue to an existing exchange. </para> <para> By default, messages will be consumed with explicit @@ -72,13 +71,16 @@ <listitem> <para> The name of the queue to consume messages - from. If the specified queue does not exist, - an auto-delete queue is created with the given - name. If this option is omitted, a new - auto-delete queue will be created, with a - unique name assigned to the queue by the AMQP - server; that unique name will be displayed on - stderr. + from. + </para> + + <para> + If the <option>--queue</option> option is + omitted, the AMQP server will assign a unique + name to the queue, and that server-assigned + name will be dixsplayed on stderr; this case + implies that an exclusive queue should be + declared. </para> </listitem> </varlistentry> @@ -87,34 +89,36 @@ <term><option>--exchange</option>=<replaceable class="parameter">exchange name</replaceable></term> <listitem> <para> - The name of the exchange to bind the queue to. - If omitted, binding is not performed. The - specified exchange should already exist unless - the <option>--exchange-type</option> option is - used to request the creation of an exchange. + Specifies that an exclusive queue should + be declared, and bound to the given exchange. + The specified exchange should already exist + unless the <option>--exchange-type</option> + option is used to request the creation of an + exchange. </para> </listitem> </varlistentry> <varlistentry> - <term><option>-t</option></term> - <term><option>--exchange-type</option>=<replaceable class="parameter">type</replaceable></term> + <term><option>-r</option></term> + <term><option>--routing-key</option>=<replaceable class="parameter">routing key</replaceable></term> <listitem> <para> - This option indicates that an auto-delete - exchange of the specified type should be - created. The name of the exchange should be - given by the <option>--exchange</option> - option. + The routing key for binding. If omitted, an + empty routing key is assumed. </para> </listitem> </varlistentry> <varlistentry> - <term><option>-r</option></term> - <term><option>--routing-key</option>=<replaceable class="parameter">routing key</replaceable></term> + <term><option>-d</option></term> + <term><option>--declare</option></term> <listitem> <para> - The routing key for the binding. If omitted, - an empty routing key is assumed. + Forces an exclusive queue to be declared, + even when it otherwise would not. That is, + when a queue name is specified with the + <option>--queue</option> option, but no + binding to an exchange is requested with the + <option>--exchange</option> option. </para> </listitem> </varlistentry> @@ -138,7 +142,7 @@ <title>Examples</title> <variablelist> <varlistentry> - <term>Consume messages from the queue + <term>Consume messages from an existing queue <quote><systemitem class="resource">myqueue</systemitem></quote>, and output the message bodies on standard output via @@ -149,7 +153,7 @@ </varlistentry> <varlistentry> - <term>Bind a newly created auto-delete queue to an + <term>Bind a new exclusive queue to an exchange <quote><systemitem class="resource">myexch</systemitem></quote>, and send each message body to the script |