1 | <?php |
||
40 | abstract class BaseAmqp |
||
41 | { |
||
42 | /** |
||
43 | * @var AbstractConnection |
||
44 | */ |
||
45 | protected $connection; |
||
46 | |||
47 | /** |
||
48 | * @var AMQPChannel |
||
49 | */ |
||
50 | protected $channel; |
||
51 | |||
52 | /** |
||
53 | * @var array |
||
54 | */ |
||
55 | protected $exchangeOptions = array( |
||
56 | 'passive' => false, |
||
57 | 'durable' => true, |
||
58 | 'auto_delete' => false, |
||
59 | 'internal' => false, |
||
60 | 'nowait' => false, |
||
61 | 'arguments' => null, |
||
62 | 'ticket' => null |
||
63 | ); |
||
64 | |||
65 | /** |
||
66 | * @var array |
||
67 | */ |
||
68 | protected $queueOptions = array( |
||
69 | 'name' => '', |
||
70 | 'passive' => false, |
||
71 | 'durable' => true, |
||
72 | 'exclusive' => false, |
||
73 | 'auto_delete' => false, |
||
74 | 'nowait' => false, |
||
75 | 'arguments' => null, |
||
76 | 'ticket' => null |
||
77 | ); |
||
78 | |||
79 | /** |
||
80 | * @var array |
||
81 | */ |
||
82 | protected $consumerOptions = array( |
||
83 | 'qos' => array() |
||
84 | ); |
||
85 | |||
86 | /** |
||
87 | * @var string |
||
88 | */ |
||
89 | protected $routingKey = ''; |
||
90 | |||
91 | /** |
||
92 | * BaseAmqp constructor. |
||
93 | * @param AbstractConnection $connection |
||
94 | */ |
||
95 | 260 | public function __construct(AbstractConnection $connection) |
|
100 | |||
101 | /** |
||
102 | * @param array $options |
||
103 | */ |
||
104 | 150 | public function setExchangeOptions(array $options) |
|
105 | { |
||
106 | 150 | if (empty($options['name'])) { |
|
107 | 25 | throw new InvalidArgumentException( |
|
108 | 5 | 'You must provide an exchange name' |
|
109 | 20 | ); |
|
110 | } |
||
111 | |||
112 | 125 | if (empty($options['type'])) { |
|
113 | 20 | throw new InvalidArgumentException( |
|
114 | 4 | 'You must provide an exchange type' |
|
115 | 16 | ); |
|
116 | } |
||
117 | |||
118 | 105 | $this->exchangeOptions = array_merge( |
|
119 | 105 | $this->exchangeOptions, |
|
120 | $options |
||
121 | 84 | ); |
|
122 | 105 | } |
|
123 | |||
124 | /** |
||
125 | * @param array $options |
||
126 | */ |
||
127 | 40 | public function setQueueOptions(array $options) |
|
134 | |||
135 | /** |
||
136 | * @param string $routingKey |
||
137 | */ |
||
138 | 5 | public function setRoutingKey($routingKey) |
|
142 | |||
143 | /** |
||
144 | * @param array $options |
||
145 | */ |
||
146 | 10 | public function setQos(array $options) |
|
150 | |||
151 | /** |
||
152 | * Setup consumer. |
||
153 | */ |
||
154 | 70 | protected function setUpConsumer() |
|
204 | |||
205 | /** |
||
206 | * @return string |
||
207 | */ |
||
208 | 40 | protected function getConsumerTag() |
|
212 | } |
||
213 |