amqp-consume.xml 9.1 KB

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