File tree Expand file tree Collapse file tree 3 files changed +77
-0
lines changed Expand file tree Collapse file tree 3 files changed +77
-0
lines changed Original file line number Diff line number Diff line change 2020 'className ' => \Proklung \Redis \Samples \FooFsProcessor::class,
2121 'tags ' => ['name ' => 'enqueue.topic_subscriber ' , 'client ' => 'filesystem ' ]
2222 ],
23+ // Пример клиента на RabbitMq
24+ 'Proklung\Redis\Samples\FooRabbitProcessor ' => [
25+ 'className ' => \Proklung \Redis \Samples \FooRabbitProcessor::class,
26+ 'tags ' => ['name ' => 'enqueue.topic_subscriber ' , 'client ' => 'rabbit ' ]
27+ ],
2328 ],
2429 'readonly ' => false ,
2530 ],
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Proklung \Redis \Samples ;
4+
5+ use Interop \Queue \Message ;
6+ use Interop \Queue \Context ;
7+ use Interop \Queue \Processor ;
8+ use Enqueue \Client \TopicSubscriberInterface ;
9+
10+ /**
11+ * Class FooRabbitProcessor
12+ * @package Proklung\Redis\Samples
13+ */
14+ class FooRabbitProcessor implements Processor, TopicSubscriberInterface
15+ {
16+ public function process (Message $ message , Context $ session )
17+ {
18+ file_put_contents ($ _SERVER ['DOCUMENT_ROOT ' ] . '/rabbit-bitrix.log ' , $ message ->getBody ());
19+
20+ return self ::ACK ;
21+ // return self::REJECT; // when the message is broken
22+ // return self::REQUEUE; // the message is fine but you want to postpone processing
23+ }
24+
25+ public static function getSubscribedTopics ()
26+ {
27+ return ['bitrix-rabbit ' ];
28+ }
29+ }
Original file line number Diff line number Diff line change 11# Модуль для Битрикса, организующий работу с очередями через Redis (и не только)
22
3+ Поддерживаемый транспорт:
4+
35- Redis
6+ - RabbitMq
47- Filesystem
58
69## Установка
@@ -194,6 +197,46 @@ return [
194197
195198## Другие транспорты
196199
200+ ### RabbitMq
201+
202+ #### Настройка
203+
204+ ` .settings.php ` Битрикса:
205+
206+ ``` php
207+ // ... предыдущее
208+
209+ 'proklung.redis' => [
210+ 'value' => [
211+ 'enqueue' => [
212+ // ... предыдущее
213+ 'rabbit' => [
214+ 'transport' => 'amqp://',
215+ 'client' => [
216+ 'default_queue' => 'default',
217+ 'prefix' => 'rabbit',
218+ 'app_name' => 'fedy',
219+ ],
220+ ],
221+ ]
222+ ]
223+ ],
224+ ```
225+
226+ Все по аналогии с Redis или файловой системой. Важно первый раз не забыть запустить ` setup-broker ` :
227+
228+ ``` bash
229+ php bin/enqueue enqueue:setup-broker --client=rabbit
230+ ```
231+
232+ #### Получение сообщений
233+
234+ ``` bash
235+ php bin/enqueue enqueue:consume --client=rabbit
236+ ```
237+
238+ Где ` rabbit ` - название клиента, определяемое в ` .settings.php ` Битрикса.
239+
197240### Файловая система
198241
199242#### Настройка
You can’t perform that action at this time.
0 commit comments