1 | <?php |
||
8 | class Delivery extends Message |
||
9 | { |
||
10 | /** |
||
11 | * @var ChannelInterface |
||
12 | */ |
||
13 | private $channel; |
||
14 | |||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | private $consumerTag; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | private $deliveryTag; |
||
24 | |||
25 | /** |
||
26 | * @var bool |
||
27 | */ |
||
28 | private $redeliver; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | private $exchange; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | private $routingKey; |
||
39 | |||
40 | /** |
||
41 | * @param ChannelInterface $channel |
||
42 | * @param string $consumerTag |
||
43 | * @param string $deliveryTag |
||
44 | * @param bool $redeliver |
||
45 | * @param string $exchange |
||
46 | * @param string $routingKey |
||
47 | * @param string $body |
||
48 | * @param array $properties |
||
49 | */ |
||
50 | 16 | public function __construct( |
|
69 | |||
70 | /** |
||
71 | * Acknowledge message, marking it as one successfully processed by consumer. |
||
72 | * |
||
73 | * @param bool $multiple |
||
74 | * |
||
75 | * @return $this |
||
76 | */ |
||
77 | 6 | public function ack($multiple = false) |
|
83 | |||
84 | /** |
||
85 | * Reject message(s) marking it as one which consumer fail to process. |
||
86 | * |
||
87 | * @param bool $requeue makes AMQP server put messages back to the queue |
||
88 | * @param bool $multiple reject all delivered and not acknowledged messages including current one |
||
89 | * |
||
90 | * @return $this |
||
91 | */ |
||
92 | 3 | public function reject($requeue = true, $multiple = false) |
|
98 | |||
99 | /** |
||
100 | * Cancel message consuming. |
||
101 | * |
||
102 | * @return $this |
||
103 | */ |
||
104 | 6 | public function cancel() |
|
105 | { |
||
106 | 6 | if (empty($this->consumerTag)) { |
|
107 | 1 | throw new \LogicException('Consumer is not assigned to this delivery.'); |
|
108 | } |
||
109 | |||
110 | 5 | $this->channel->cancel($this->consumerTag); |
|
111 | |||
112 | 5 | return $this; |
|
113 | } |
||
114 | |||
115 | /** |
||
116 | * Consume tag - unique identifier of the consumer within a channel. |
||
117 | * Used to identify consumer in frames related to it, like basic.cancel. |
||
118 | * |
||
119 | * @return string |
||
120 | */ |
||
121 | 2 | public function getConsumerTag() |
|
125 | |||
126 | /** |
||
127 | * Delivery tag - unique identifier of the delivery within a channel. |
||
128 | * Used to identify delivery in frames related to it, like basic.ack or basic.reject. |
||
129 | * |
||
130 | * @return string |
||
131 | */ |
||
132 | 2 | public function getDeliveryTag() |
|
136 | |||
137 | /** |
||
138 | * Redeliver is true if message was rejected before with re-enqueue set to true. |
||
139 | * |
||
140 | * @return bool |
||
141 | */ |
||
142 | 2 | public function isRedeliver() |
|
146 | |||
147 | /** |
||
148 | * Exchange where message was sent initially. |
||
149 | * |
||
150 | * @return string |
||
151 | */ |
||
152 | 3 | public function getExchange() |
|
156 | |||
157 | /** |
||
158 | * Routing key. |
||
159 | * |
||
160 | * @return string |
||
161 | */ |
||
162 | 3 | public function getRoutingKey() |
|
166 | |||
167 | /** |
||
168 | * Define how to print object when dumping. |
||
169 | * |
||
170 | * @return array |
||
171 | */ |
||
172 | 1 | public function __debugInfo() |
|
183 | } |
||
184 |