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 | * @param array $options |
||
113 | */ |
||
114 | 135 | public function setExchangeOptions(array $options) |
|
133 | |||
134 | /** |
||
135 | * @param array $options |
||
136 | */ |
||
137 | 40 | public function setQueueOptions(array $options) |
|
144 | |||
145 | /** |
||
146 | * @param string $routingKey |
||
147 | */ |
||
148 | 5 | public function setRoutingKey($routingKey) |
|
152 | |||
153 | /** |
||
154 | * @param array $options |
||
155 | */ |
||
156 | 10 | public function setQos(array $options) |
|
160 | |||
161 | /** |
||
162 | * Setup consumer. |
||
163 | */ |
||
164 | 70 | protected function setUpConsumer() |
|
218 | |||
219 | /** |
||
220 | * @return string |
||
221 | */ |
||
222 | 40 | protected function getConsumerTag() |
|
226 | |||
227 | /** |
||
228 | * Verifies exchange name meets the 0.9.1 protocol standard. |
||
229 | * |
||
230 | * letters, digits, hyphen, underscore, period, or colon |
||
231 | * |
||
232 | * @param string $exchangeName |
||
233 | * @return bool |
||
234 | */ |
||
235 | 125 | private function isValidExchangeName($exchangeName) |
|
239 | |||
240 | /** |
||
241 | * @param string $key |
||
242 | * @param string $value |
||
243 | */ |
||
244 | 35 | public function setParameter($key, $value) |
|
248 | |||
249 | /** |
||
250 | * @return array |
||
251 | */ |
||
252 | 35 | public function getParameters() |
|
256 | } |
||
257 |