| 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.docbook.org/xml/4.5/docbookx.dtd" |
| 3 | [ |
| 4 | <!ENTITY date SYSTEM "man-date.ent" > |
| 5 | ] |
| 6 | > |
| 7 | <refentry lang="en"> |
| 8 | <refentryinfo> |
| 9 | <productname>RabbitMQ C Client</productname> |
| 10 | <authorgroup> |
| 11 | <corpauthor>The RabbitMQ Team <<ulink url="mailto:[email protected]"><email>[email protected]</email></ulink>></corpauthor> |
| 12 | </authorgroup> |
| 13 | <date>&date;</date> |
| 14 | </refentryinfo> |
| 15 | |
| 16 | <refmeta> |
| 17 | <refentrytitle>amqp-consume</refentrytitle> |
| 18 | <manvolnum>1</manvolnum> |
| 19 | <refmiscinfo class="manual">RabbitMQ C Client</refmiscinfo> |
| 20 | </refmeta> |
| 21 | |
| 22 | <refnamediv> |
| 23 | <refname>amqp-consume</refname> |
| 24 | <refpurpose>Consume messages from a queue on an AMQP server</refpurpose> |
| 25 | </refnamediv> |
| 26 | |
| 27 | <refsynopsisdiv> |
| 28 | <cmdsynopsis> |
| 29 | <command>amqp-consume</command> |
| 30 | <arg choice="opt" rep="repeat"> |
| 31 | <replaceable>OPTION</replaceable> |
| 32 | </arg> |
| 33 | <arg choice="req"> |
| 34 | <replaceable>command</replaceable> |
| 35 | </arg> |
| 36 | <arg choice="opt" rep="repeat"> |
| 37 | <replaceable>args</replaceable> |
| 38 | </arg> |
| 39 | </cmdsynopsis> |
| 40 | </refsynopsisdiv> |
| 41 | |
| 42 | <refsect1> |
| 43 | <title>Description</title> |
| 44 | <para> |
| 45 | <command>amqp-consume</command> consumes messages from a |
| 46 | queue on an AMQP server. For each message that arrives, a |
| 47 | receiving command is run, with the message body supplied |
| 48 | to it on standard input. |
| 49 | </para> |
| 50 | <para> |
| 51 | <command>amqp-consume</command> can consume from an |
| 52 | existing queue, or it can create a new queue. It can |
| 53 | optionally bind the queue to an existing exchange. |
| 54 | </para> |
| 55 | <para> |
| 56 | By default, messages will be consumed with explicit |
| 57 | acknowledgements. A message will only be acknowledged if |
| 58 | the receiving command exits successfully (i.e. with an |
| 59 | exit code of zero). The AMQP <quote>no ack</quote> mode |
| 60 | (a.k.a. auto-ack mode) can be enable with the |
| 61 | <option>-A</option> option. |
| 62 | </para> |
| 63 | </refsect1> |
| 64 | |
| 65 | <refsect1> |
| 66 | <title>Options</title> |
| 67 | <variablelist> |
| 68 | <varlistentry> |
| 69 | <term><option>-q</option></term> |
| 70 | <term><option>--queue</option>=<replaceable class="parameter">queue name</replaceable></term> |
| 71 | <listitem> |
| 72 | <para> |
| 73 | The name of the queue to consume messages |
| 74 | from. |
| 75 | </para> |
| 76 | |
| 77 | <para> |
| 78 | If the <option>--queue</option> option is |
| 79 | omitted, the AMQP server will assign a unique |
| 80 | name to the queue, and that server-assigned |
| 81 | name will be dixsplayed on stderr; this case |
| 82 | implies that an exclusive queue should be |
| 83 | declared. |
| 84 | </para> |
| 85 | </listitem> |
| 86 | </varlistentry> |
| 87 | <varlistentry> |
| 88 | <term><option>-e</option></term> |
| 89 | <term><option>--exchange</option>=<replaceable class="parameter">exchange name</replaceable></term> |
| 90 | <listitem> |
| 91 | <para> |
| 92 | Specifies that an exclusive queue should |
| 93 | be declared, and bound to the given exchange. |
| 94 | The specified exchange should already exist |
| 95 | unless the <option>--exchange-type</option> |
| 96 | option is used to request the creation of an |
| 97 | exchange. |
| 98 | </para> |
| 99 | </listitem> |
| 100 | </varlistentry> |
| 101 | <varlistentry> |
| 102 | <term><option>-r</option></term> |
| 103 | <term><option>--routing-key</option>=<replaceable class="parameter">routing key</replaceable></term> |
| 104 | <listitem> |
| 105 | <para> |
| 106 | The routing key for binding. If omitted, an |
| 107 | empty routing key is assumed. |
| 108 | </para> |
| 109 | </listitem> |
| 110 | </varlistentry> |
| 111 | <varlistentry> |
| 112 | <term><option>-d</option></term> |
| 113 | <term><option>--declare</option></term> |
| 114 | <listitem> |
| 115 | <para> |
| 116 | Forces an exclusive queue to be declared, |
| 117 | even when it otherwise would not be. That is, |
| 118 | when a queue name is specified with the |
| 119 | <option>--queue</option> option, but no |
| 120 | binding to an exchange is requested with the |
| 121 | <option>--exchange</option> option. |
| 122 | Note: this option is deprecated and may be |
| 123 | removed in a future version, use the |
| 124 | <option>--exclusive</option> option to |
| 125 | explicitly declare an exclusive queue. |
| 126 | </para> |
| 127 | </listitem> |
| 128 | </varlistentry> |
| 129 | <varlistentry> |
| 130 | <term><option>-x</option></term> |
| 131 | <term><option>--exclusive</option></term> |
| 132 | <listitem> |
| 133 | <para> |
| 134 | Declared queues are non-exclusive by default, |
| 135 | this option forces declaration of exclusive |
| 136 | queues. |
| 137 | </para> |
| 138 | </listitem> |
| 139 | </varlistentry> |
| 140 | <varlistentry> |
| 141 | <term><option>-A</option></term> |
| 142 | <term><option>--no-ack</option>=<replaceable class="parameter">routing key</replaceable></term> |
| 143 | <listitem> |
| 144 | <para> |
| 145 | Enable <quote>no ack</quote> mode: The AMQP |
| 146 | server will unconditionally acknowledge each |
| 147 | message that is delivered, regardless of |
| 148 | whether the target command exits successfully |
| 149 | or not. |
| 150 | </para> |
| 151 | </listitem> |
| 152 | </varlistentry> |
| 153 | <varlistentry> |
| 154 | <term><option>-c</option></term> |
| 155 | <term><option>--count</option>=<replaceable class="parameter">limit</replaceable></term> |
| 156 | <listitem> |
| 157 | <para> |
| 158 | Stop consuming after the given number of |
| 159 | messages have been received. |
| 160 | </para> |
| 161 | </listitem> |
| 162 | </varlistentry> |
| 163 | <varlistentry> |
| 164 | <term><option>-p</option></term> |
| 165 | <term><option>--prefetch-count</option>=<replaceable class="parameter">limit</replaceable></term> |
| 166 | <listitem> |
| 167 | <para> |
| 168 | Request the server to only send |
| 169 | <replaceable class="parameter">limit</replaceable> |
| 170 | messages at a time. |
| 171 | </para> |
| 172 | <para> |
| 173 | If any value was passed to <option>--count</option>, |
| 174 | the value passed to <option>--prefetch-count</option> |
| 175 | should be smaller than that, or otherwise it will be |
| 176 | ignored. |
| 177 | </para> |
| 178 | <para> |
| 179 | If <option>-A</option>/<option>--no-ack</option> is |
| 180 | passed, this option has no effect. |
| 181 | </para> |
| 182 | </listitem> |
| 183 | </varlistentry> |
| 184 | </variablelist> |
| 185 | </refsect1> |
| 186 | |
| 187 | <refsect1> |
| 188 | <title>Examples</title> |
| 189 | <variablelist> |
| 190 | <varlistentry> |
| 191 | <term>Consume messages from an existing queue |
| 192 | <quote><systemitem |
| 193 | class="resource">myqueue</systemitem></quote>, and |
| 194 | output the message bodies on standard output via |
| 195 | <command>cat</command>:</term> |
| 196 | <listitem> |
| 197 | <screen><prompt>$ </prompt><userinput>amqp-consume -q myqueue cat</userinput></screen> |
| 198 | </listitem> |
| 199 | </varlistentry> |
| 200 | |
| 201 | <varlistentry> |
| 202 | <term>Bind a new exclusive queue to an |
| 203 | exchange <quote><systemitem |
| 204 | class="resource">myexch</systemitem></quote>, and send |
| 205 | each message body to the script |
| 206 | <filename>myscript</filename>, automatically |
| 207 | acknowledging them on the server:</term> |
| 208 | <listitem> |
| 209 | <screen><prompt>$ </prompt><userinput>amqp-consume -A -e myexch ./myscript</userinput></screen> |
| 210 | </listitem> |
| 211 | </varlistentry> |
| 212 | </variablelist> |
| 213 | </refsect1> |
| 214 | |
| 215 | <refsect1> |
| 216 | <title>See also</title> |
| 217 | <para> |
| 218 | <citerefentry><refentrytitle>librabbitmq-tools</refentrytitle><manvolnum>7</manvolnum></citerefentry> |
| 219 | describes connection-related options common to all the |
| 220 | RabbitMQ C Client tools. |
| 221 | </para> |
| 222 | </refsect1> |
| 223 | </refentry> |