|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Cmobi\RabbitmqBundle\Transport\PubSub; |
|
4
|
|
|
|
|
5
|
|
|
use Cmobi\RabbitmqBundle\Queue\QueueBagInterface; |
|
6
|
|
|
|
|
7
|
|
|
class SubscriberQueueBag implements QueueBagInterface |
|
8
|
|
|
{ |
|
9
|
|
|
private $options; |
|
10
|
|
|
|
|
11
|
|
|
public function __construct( |
|
12
|
|
|
$exchange, |
|
13
|
|
|
$type = ExchangeType::FANOUT, |
|
14
|
|
|
$queueName = null, |
|
15
|
|
|
$basicQos = 1, |
|
16
|
|
|
$passive = false, |
|
17
|
|
|
$durable = false, |
|
18
|
|
|
$declareExclusive = true, |
|
19
|
|
|
$consumeExclusive = false, |
|
20
|
|
|
$internal = false, |
|
21
|
|
|
$autoDelete = false, |
|
22
|
|
|
$noWait = false, |
|
23
|
|
|
array $arguments = null, |
|
24
|
|
|
$ticket = null, |
|
25
|
|
|
$consumerTag = '', |
|
26
|
|
|
$noAck = true, |
|
27
|
|
|
$noLocal = false |
|
28
|
|
|
) { |
|
29
|
|
|
$this->options = [ |
|
30
|
|
|
'exchange' => $exchange, |
|
31
|
|
|
'type' => $type, |
|
32
|
|
|
'basic_qos' => $basicQos, |
|
33
|
|
|
'queue_name' => $queueName, |
|
34
|
|
|
'passive' => $passive, |
|
35
|
|
|
'durable' => $durable, |
|
36
|
|
|
'declare_exclusive' => $declareExclusive, |
|
37
|
|
|
'consume_exclusive' => $consumeExclusive, |
|
38
|
|
|
'internal' => $internal, |
|
39
|
|
|
'auto_delete' => $autoDelete, |
|
40
|
|
|
'no_wait' => $noWait, |
|
41
|
|
|
'arguments' => $arguments, |
|
42
|
|
|
'ticket' => $ticket, |
|
43
|
|
|
'consumer_tag' => $consumerTag, |
|
44
|
|
|
'no_ack' => $noAck, |
|
45
|
|
|
'no_local' => $noLocal, |
|
46
|
|
|
]; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param $exchange |
|
51
|
|
|
*/ |
|
52
|
|
|
public function setExchange($exchange) |
|
53
|
|
|
{ |
|
54
|
|
|
$this->options['exchange'] = $exchange; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @return string|mixed |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getExchange() |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->options['exchange']; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @param $qos |
|
67
|
|
|
*/ |
|
68
|
|
|
public function setBasicQos($qos) |
|
69
|
|
|
{ |
|
70
|
|
|
$this->options['basic_qos'] = $qos; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @return int |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getBasicQos() |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->options['basic_qos']; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @param $queueName |
|
83
|
|
|
*/ |
|
84
|
|
|
public function setQueueName($queueName) |
|
85
|
|
|
{ |
|
86
|
|
|
$this->options['queue_name'] = $queueName; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @return string |
|
91
|
|
|
*/ |
|
92
|
|
|
public function getQueueName() |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->options['queue_name']; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @param $type |
|
99
|
|
|
*/ |
|
100
|
|
|
public function setType($type) |
|
101
|
|
|
{ |
|
102
|
|
|
$this->options['type'] = $type; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* @return string |
|
107
|
|
|
*/ |
|
108
|
|
|
public function getType() |
|
109
|
|
|
{ |
|
110
|
|
|
return $this->options['type']; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* @param $passive |
|
115
|
|
|
*/ |
|
116
|
|
|
public function setPassive($passive) |
|
117
|
|
|
{ |
|
118
|
|
|
$this->options['passive'] = $passive; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* @return bool |
|
123
|
|
|
*/ |
|
124
|
|
|
public function getPassive() |
|
125
|
|
|
{ |
|
126
|
|
|
return $this->options['passive']; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* @param $internal |
|
131
|
|
|
*/ |
|
132
|
|
|
public function setInternal($internal) |
|
133
|
|
|
{ |
|
134
|
|
|
$this->options['internal'] = $internal; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* @return bool |
|
139
|
|
|
*/ |
|
140
|
|
|
public function getInternal() |
|
141
|
|
|
{ |
|
142
|
|
|
return $this->options['internal']; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* @param $durable |
|
147
|
|
|
*/ |
|
148
|
|
|
public function setDurable($durable) |
|
149
|
|
|
{ |
|
150
|
|
|
$this->options['durable'] = $durable; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* @return bool |
|
155
|
|
|
*/ |
|
156
|
|
|
public function getDurable() |
|
157
|
|
|
{ |
|
158
|
|
|
return $this->options['durable']; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* @param $exclusive |
|
163
|
|
|
*/ |
|
164
|
|
|
public function setDeclareExclusive($exclusive) |
|
165
|
|
|
{ |
|
166
|
|
|
$this->options['declare_exclusive'] = $exclusive; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* @return bool |
|
171
|
|
|
*/ |
|
172
|
|
|
public function getDeclareExclusive() |
|
173
|
|
|
{ |
|
174
|
|
|
return $this->options['declare_exclusive']; |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* @param $exclusive |
|
179
|
|
|
*/ |
|
180
|
|
|
public function setConsumeExclusive($exclusive) |
|
181
|
|
|
{ |
|
182
|
|
|
$this->options['consume_exclusive'] = $exclusive; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
/** |
|
186
|
|
|
* @return bool |
|
187
|
|
|
*/ |
|
188
|
|
|
public function getConsumeExclusive() |
|
189
|
|
|
{ |
|
190
|
|
|
return $this->options['consume_exclusive']; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* @param $autoDelete |
|
195
|
|
|
*/ |
|
196
|
|
|
public function setAutoDelete($autoDelete) |
|
197
|
|
|
{ |
|
198
|
|
|
$this->options['auto_delete'] = $autoDelete; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* @return bool |
|
203
|
|
|
*/ |
|
204
|
|
|
public function getAutoDelete() |
|
205
|
|
|
{ |
|
206
|
|
|
return $this->options['auto_delete']; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/** |
|
210
|
|
|
* @param $noWait |
|
211
|
|
|
*/ |
|
212
|
|
|
public function setNoWait($noWait) |
|
213
|
|
|
{ |
|
214
|
|
|
$this->options['no_wait'] = $noWait; |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
/** |
|
218
|
|
|
* @return bool |
|
219
|
|
|
*/ |
|
220
|
|
|
public function getNoWait() |
|
221
|
|
|
{ |
|
222
|
|
|
return $this->options['no_wait']; |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
/** |
|
226
|
|
|
* @param array $arguments |
|
227
|
|
|
*/ |
|
228
|
|
|
public function setArguments(array $arguments) |
|
229
|
|
|
{ |
|
230
|
|
|
$this->options['arguments'] = $arguments; |
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
|
|
/** |
|
234
|
|
|
* @return string |
|
235
|
|
|
*/ |
|
236
|
|
|
public function getArguments() |
|
237
|
|
|
{ |
|
238
|
|
|
return $this->options['arguments']; |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
/** |
|
242
|
|
|
* @param $ticket |
|
243
|
|
|
*/ |
|
244
|
|
|
public function setTicket($ticket) |
|
245
|
|
|
{ |
|
246
|
|
|
$this->options['ticket'] = $ticket; |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
/** |
|
250
|
|
|
* @return string |
|
251
|
|
|
*/ |
|
252
|
|
|
public function getTicket() |
|
253
|
|
|
{ |
|
254
|
|
|
return $this->options['ticket']; |
|
255
|
|
|
} |
|
256
|
|
|
|
|
257
|
|
|
/** |
|
258
|
|
|
* @param $consumerTag |
|
259
|
|
|
*/ |
|
260
|
|
|
public function setConsumerTag($consumerTag) |
|
261
|
|
|
{ |
|
262
|
|
|
$this->options['consumer_tag'] = $consumerTag; |
|
263
|
|
|
} |
|
264
|
|
|
|
|
265
|
|
|
/** |
|
266
|
|
|
* @return string |
|
267
|
|
|
*/ |
|
268
|
|
|
public function getConsumerTag() |
|
269
|
|
|
{ |
|
270
|
|
|
return $this->options['consumer_tag']; |
|
271
|
|
|
} |
|
272
|
|
|
|
|
273
|
|
|
/** |
|
274
|
|
|
* @param $noAck |
|
275
|
|
|
*/ |
|
276
|
|
|
public function setNoAck($noAck) |
|
277
|
|
|
{ |
|
278
|
|
|
$this->options['no_ack'] = $noAck; |
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
|
|
/** |
|
282
|
|
|
* @return bool |
|
283
|
|
|
*/ |
|
284
|
|
|
public function getNoAck() |
|
285
|
|
|
{ |
|
286
|
|
|
return $this->options['no_ack']; |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
/** |
|
290
|
|
|
* @param $noLocal |
|
291
|
|
|
*/ |
|
292
|
|
|
public function setNoLocal($noLocal) |
|
293
|
|
|
{ |
|
294
|
|
|
$this->options['no_local'] = $noLocal; |
|
295
|
|
|
} |
|
296
|
|
|
|
|
297
|
|
|
/** |
|
298
|
|
|
* @return bool |
|
299
|
|
|
*/ |
|
300
|
|
|
public function getNoLocal() |
|
301
|
|
|
{ |
|
302
|
|
|
return $this->options['no_local']; |
|
303
|
|
|
} |
|
304
|
|
|
|
|
305
|
|
|
/** |
|
306
|
|
|
* @return array |
|
307
|
|
|
*/ |
|
308
|
|
|
public function getQueueDeclare() |
|
309
|
|
|
{ |
|
310
|
|
|
return [ |
|
311
|
|
|
$this->getQueueName(), |
|
312
|
|
|
$this->getPassive(), |
|
313
|
|
|
$this->getDurable(), |
|
314
|
|
|
$this->getDeclareExclusive(), |
|
315
|
|
|
$this->getAutoDelete(), |
|
316
|
|
|
$this->getNoWait(), |
|
317
|
|
|
$this->getArguments(), |
|
318
|
|
|
$this->getTicket(), |
|
319
|
|
|
]; |
|
320
|
|
|
} |
|
321
|
|
|
|
|
322
|
|
|
/** |
|
323
|
|
|
* @return array |
|
324
|
|
|
*/ |
|
325
|
|
|
public function getQueueConsume() |
|
326
|
|
|
{ |
|
327
|
|
|
return [ |
|
328
|
|
|
$this->getQueueName(), |
|
329
|
|
|
$this->getConsumerTag(), |
|
330
|
|
|
$this->getNoLocal(), |
|
331
|
|
|
$this->getNoAck(), |
|
332
|
|
|
$this->getConsumeExclusive(), |
|
333
|
|
|
$this->getNoWait(), |
|
334
|
|
|
$this->getTicket(), |
|
335
|
|
|
$this->getArguments(), |
|
336
|
|
|
]; |
|
337
|
|
|
} |
|
338
|
|
|
|
|
339
|
|
|
public function getExchangeDeclare() |
|
340
|
|
|
{ |
|
341
|
|
|
return [ |
|
342
|
|
|
$this->getExchange(), |
|
343
|
|
|
$this->getType(), |
|
344
|
|
|
$this->getPassive(), |
|
345
|
|
|
$this->getDurable(), |
|
346
|
|
|
$this->getAutoDelete(), |
|
347
|
|
|
$this->getInternal(), |
|
348
|
|
|
$this->getNoWait(), |
|
349
|
|
|
$this->getArguments(), |
|
350
|
|
|
$this->getTicket(), |
|
351
|
|
|
]; |
|
352
|
|
|
} |
|
353
|
|
|
|
|
354
|
|
|
/** |
|
355
|
|
|
* @return string|mixed |
|
356
|
|
|
*/ |
|
357
|
|
|
public function getQueue() |
|
358
|
|
|
{ |
|
359
|
|
|
return $this->getQueueName(); |
|
360
|
|
|
} |
|
361
|
|
|
|
|
362
|
|
|
/** |
|
363
|
|
|
* @return bool |
|
364
|
|
|
*/ |
|
365
|
|
|
public function getExclusive() |
|
366
|
|
|
{ |
|
367
|
|
|
return false; |
|
368
|
|
|
} |
|
369
|
|
|
} |
|
370
|
|
|
|