1 | <?php |
||
20 | class Queue implements QueueInterface |
||
21 | { |
||
22 | /** |
||
23 | * @var Channel |
||
24 | */ |
||
25 | protected $channel; |
||
26 | /** |
||
27 | * @var Options\QueueOptions |
||
28 | */ |
||
29 | protected $options; |
||
30 | /** |
||
31 | * @var MessageMapper |
||
32 | */ |
||
33 | protected $messageMapper; |
||
34 | |||
35 | /** |
||
36 | * Declare a new queue on the broker. |
||
37 | * |
||
38 | * @return integer the message count. |
||
39 | */ |
||
40 | 7 | public function declareQueue() |
|
54 | |||
55 | /** |
||
56 | * Bind the given queue to a routing key on an exchange. |
||
57 | * |
||
58 | * @param string $exchangeName Name of the exchange to bind to. |
||
59 | * @param string $routingKey Pattern or routing key to bind with. |
||
60 | * @param bool $noWait No wait for a reply |
||
61 | * @param array $arguments Additional binding arguments. |
||
62 | * |
||
63 | * @return boolean |
||
64 | */ |
||
65 | 7 | public function bind($exchangeName, $routingKey = null, $noWait = false, array $arguments = []) |
|
75 | |||
76 | /** |
||
77 | * Remove a routing key binding on an exchange from the given queue. |
||
78 | * |
||
79 | * @param string $exchangeName The name of the exchange on which the |
||
80 | * queue is bound. |
||
81 | * @param string $routingKey The binding routing key used by the |
||
82 | * queue. |
||
83 | * @param array $arguments Additional binding arguments. |
||
84 | * |
||
85 | * @return $this |
||
86 | */ |
||
87 | 2 | public function unbind($exchangeName, $routingKey = null, array $arguments = []) |
|
97 | |||
98 | /** |
||
99 | * Acknowledge the receipt of a message. |
||
100 | * |
||
101 | * @param string $deliveryTag The message delivery tag of which to |
||
102 | * acknowledge receipt. |
||
103 | * @param bool $multiple Acknowledge all previous |
||
104 | * unacked messages as well. |
||
105 | * |
||
106 | * @return $this |
||
107 | */ |
||
108 | 3 | public function ack($deliveryTag, $multiple = false) |
|
114 | |||
115 | /** |
||
116 | * Mark a message as explicitly not acknowledged. |
||
117 | * |
||
118 | * Mark the message identified by delivery_tag as explicitly not |
||
119 | * acknowledged. This method can only be called on messages that have not |
||
120 | * yet been acknowledged. When called, the broker will immediately put the |
||
121 | * message back onto the queue, instead of waiting until the connection is |
||
122 | * closed. This method is only supported by the RabbitMQ broker. The |
||
123 | * behavior of calling this method while connected to any other broker is |
||
124 | * undefined. |
||
125 | * |
||
126 | * @param string $deliveryTag Delivery tag of last message to reject. |
||
127 | * @param bool $requeue Requeue the message(s). |
||
128 | * @param bool $multiple Mark as not acknowledge all previous |
||
129 | * unacked messages as well. |
||
130 | * |
||
131 | * @return $this |
||
132 | */ |
||
133 | 4 | public function nack($deliveryTag, $requeue = false, $multiple = false) |
|
139 | |||
140 | /** |
||
141 | * Mark one message as explicitly not acknowledged. |
||
142 | * |
||
143 | * Mark the message identified by delivery_tag as explicitly not |
||
144 | * acknowledged. This method can only be called on messages that have not |
||
145 | * yet been acknowledged. |
||
146 | * |
||
147 | * @param string $deliveryTag Delivery tag of the message to reject. |
||
148 | * @param bool $requeue Requeue the message(s). |
||
149 | * |
||
150 | * @return $this |
||
151 | */ |
||
152 | 3 | public function reject($deliveryTag, $requeue = false) |
|
158 | |||
159 | /** |
||
160 | * Purge the contents of a queue. |
||
161 | * |
||
162 | * @return $this |
||
163 | */ |
||
164 | 1 | public function purge() |
|
170 | |||
171 | /** |
||
172 | * Cancel a queue that is already bound to an exchange and routing key. |
||
173 | * |
||
174 | * @param string $consumerTag The queue name to cancel, if the queue |
||
175 | * object is not already representative of |
||
176 | * a queue. |
||
177 | * |
||
178 | * @return $this |
||
179 | */ |
||
180 | 4 | public function cancel($consumerTag = '') |
|
186 | |||
187 | /** |
||
188 | * Delete a queue from the broker. |
||
189 | * |
||
190 | * This includes its entire contents of unread or unacknowledged messages. |
||
191 | * |
||
192 | * @param bool $ifUnused Optionally $ifUnused can be specified |
||
193 | * to indicate the queue should not be |
||
194 | * deleted until no clients are connected to |
||
195 | * it. |
||
196 | * @param bool $ifEmpty Optionally $ifUnused can be specified |
||
197 | * to indicate the queue should not be |
||
198 | * deleted until it's empty |
||
199 | * @param bool $noWait No wait for a reply |
||
200 | * |
||
201 | * @return $this |
||
202 | * @throws Exception\InvalidArgumentException |
||
203 | */ |
||
204 | 8 | public function delete($ifUnused = false, $ifEmpty = false, $noWait = false) |
|
210 | |||
211 | /** |
||
212 | * Retrieve the next message from the queue. |
||
213 | * |
||
214 | * @param bool $autoAck |
||
215 | * @return null|Message |
||
216 | * @throws \OutOfBoundsException |
||
217 | */ |
||
218 | 4 | public function get($autoAck = false) |
|
228 | |||
229 | /** |
||
230 | * @return Options\QueueOptions |
||
231 | */ |
||
232 | 12 | public function getOptions() |
|
236 | |||
237 | /** |
||
238 | * @param Options\QueueOptions|\Traversable|array $options |
||
239 | * @return $this |
||
240 | * @throws BaseException\BadMethodCallException |
||
241 | * @throws BaseException\InvalidArgumentException |
||
242 | */ |
||
243 | 36 | public function setOptions($options) |
|
251 | |||
252 | /** |
||
253 | * @return MessageMapper |
||
254 | */ |
||
255 | 10 | public function getMessageMapper() |
|
262 | |||
263 | /** |
||
264 | * @param MessageMapper $messageMapper |
||
265 | * @return $this |
||
266 | */ |
||
267 | 5 | public function setMessageMapper(MessageMapper $messageMapper) |
|
272 | |||
273 | /** |
||
274 | * Consume messages from a queue (blocking function). |
||
275 | * |
||
276 | * @param callback|ConsumerInterface|null $callback A callback function to which the |
||
277 | * consumed message will be passed. |
||
278 | * @param bool $noLocal |
||
279 | * @param bool $autoAck |
||
280 | * @param bool $exclusive |
||
281 | * @param string $consumerTag A string describing this consumer. Used |
||
282 | * for canceling subscriptions with cancel(). |
||
283 | * @return $this |
||
284 | */ |
||
285 | 6 | public function consume( |
|
313 | |||
314 | /** |
||
315 | * Get the Channel object in use |
||
316 | * |
||
317 | * @return ChannelInterface |
||
318 | */ |
||
319 | 1 | public function getChannel() |
|
323 | |||
324 | /** |
||
325 | * @param Channel $channel |
||
326 | * @return $this |
||
327 | */ |
||
328 | 36 | public function setChannel(Channel $channel) |
|
333 | |||
334 | /** |
||
335 | * Get the Connection object in use |
||
336 | * |
||
337 | * @return ConnectionInterface |
||
338 | */ |
||
339 | 1 | public function getConnection() |
|
343 | } |
||
344 |