1 | <?php |
||
40 | abstract class BaseAmqp |
||
41 | { |
||
42 | const NON_PERSISTENT = 1; |
||
43 | const PERSISTENT = 2; |
||
44 | |||
45 | /** |
||
46 | * @var AbstractConnection |
||
47 | */ |
||
48 | protected $connection; |
||
49 | |||
50 | /** |
||
51 | * @var AMQPChannel |
||
52 | */ |
||
53 | protected $channel; |
||
54 | |||
55 | /** |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $exchangeOptions = array( |
||
59 | 'passive' => false, |
||
60 | 'durable' => true, |
||
61 | 'auto_delete' => false, |
||
62 | 'internal' => false, |
||
63 | 'nowait' => false, |
||
64 | 'arguments' => null, |
||
65 | 'ticket' => null |
||
66 | ); |
||
67 | |||
68 | /** |
||
69 | * @var array |
||
70 | */ |
||
71 | protected $queueOptions = array( |
||
72 | 'name' => '', |
||
73 | 'passive' => false, |
||
74 | 'durable' => true, |
||
75 | 'exclusive' => false, |
||
76 | 'auto_delete' => false, |
||
77 | 'nowait' => false, |
||
78 | 'arguments' => null, |
||
79 | 'ticket' => null |
||
80 | ); |
||
81 | |||
82 | /** |
||
83 | * @var array |
||
84 | */ |
||
85 | protected $consumerOptions = array( |
||
86 | 'qos' => array() |
||
87 | ); |
||
88 | |||
89 | /** |
||
90 | * @var string |
||
91 | */ |
||
92 | protected $routingKey = ''; |
||
93 | |||
94 | /** |
||
95 | * @var array |
||
96 | */ |
||
97 | protected $parameters = array( |
||
98 | 'content_type' => 'text/plain' |
||
99 | ); |
||
100 | |||
101 | /** |
||
102 | * BaseAmqp constructor. |
||
103 | * @param AbstractConnection $connection |
||
104 | */ |
||
105 | 245 | public function __construct(AbstractConnection $connection) |
|
110 | |||
111 | /** |
||
112 | * @return AMQPChannel |
||
113 | */ |
||
114 | public function getChannel() { |
||
117 | |||
118 | /** |
||
119 | * @param array $options |
||
120 | */ |
||
121 | 135 | public function setExchangeOptions(array $options) |
|
140 | |||
141 | /** |
||
142 | * @param array $options |
||
143 | */ |
||
144 | 40 | public function setQueueOptions(array $options) |
|
151 | |||
152 | /** |
||
153 | * @param string $routingKey |
||
154 | */ |
||
155 | 5 | public function setRoutingKey($routingKey) |
|
159 | |||
160 | /** |
||
161 | * @param array $options |
||
162 | */ |
||
163 | 10 | public function setQos(array $options) |
|
167 | |||
168 | /** |
||
169 | * Setup consumer. |
||
170 | */ |
||
171 | 70 | protected function setUpConsumer() |
|
225 | |||
226 | /** |
||
227 | * @return string |
||
228 | */ |
||
229 | 40 | protected function getConsumerTag() |
|
233 | |||
234 | /** |
||
235 | * Verifies exchange name meets the 0.9.1 protocol standard. |
||
236 | * |
||
237 | * letters, digits, hyphen, underscore, period, or colon |
||
238 | * |
||
239 | * @param string $exchangeName |
||
240 | * @return bool |
||
241 | */ |
||
242 | 125 | private function isValidExchangeName($exchangeName) |
|
246 | |||
247 | /** |
||
248 | * @param string $key |
||
249 | * @param string $value |
||
250 | */ |
||
251 | 35 | public function setParameter($key, $value) |
|
255 | |||
256 | /** |
||
257 | * @return array |
||
258 | */ |
||
259 | 35 | public function getParameters() |
|
263 | } |
||
264 |