1 | <?php |
||
26 | class RabbitMqWorker extends BaseSymfonyWorker implements ConsumerInterface |
||
27 | { |
||
28 | |||
29 | /** |
||
30 | * Rabbit MQ worker subsystem name. |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | const SUBSYSTEM_NAME = "RabbitMqworker"; |
||
35 | |||
36 | /** |
||
37 | * Serializer instance. |
||
38 | * |
||
39 | * @var Serializer |
||
40 | */ |
||
41 | private $serializer; |
||
42 | |||
43 | /** |
||
44 | * Reschedule producer instance. |
||
45 | * |
||
46 | * @var ProducerInterface |
||
47 | */ |
||
48 | private $rescheduleProducer; |
||
49 | |||
50 | /** |
||
51 | * Class constructor. |
||
52 | * |
||
53 | * @param EventDispatcherInterface $eventDispatcher Symfony event dispatcher. |
||
54 | * @param ProcessorFactoryInterface $processorFactory |
||
55 | * @param Serializer $serializer |
||
56 | * @param ProducerInterface $rescheduleProducer |
||
57 | * @param LoggerInterface $logger Logger instance. |
||
58 | */ |
||
59 | 7 | public function __construct(EventDispatcherInterface $eventDispatcher, ProcessorFactoryInterface $processorFactory, Serializer $serializer, ProducerInterface $rescheduleProducer, LoggerInterface $logger = null) |
|
66 | |||
67 | /** |
||
68 | * Process single message received from RabbitMq server. |
||
69 | * |
||
70 | * @param AMQPMessage $msg |
||
71 | * |
||
72 | * @return null|integer Return code, dictating further message status. |
||
73 | */ |
||
74 | 7 | public function execute(AMQPMessage $msg) |
|
91 | |||
92 | 7 | protected function translateCommand($commandData) |
|
108 | |||
109 | 7 | public function getSubsystemName() |
|
113 | |||
114 | /** |
||
115 | * Send message for rescheduler, if maximum number of tries has not been exceeded. |
||
116 | * |
||
117 | * @param AMQPMessage $msg |
||
118 | * @param Exception $e |
||
119 | * @param CommandProcessorInterface $processor |
||
120 | */ |
||
121 | 6 | private function maybeReschedule(AMQPMessage $msg, Exception $e, CommandProcessorInterface $processor = null) |
|
143 | |||
144 | /** |
||
145 | * Get retry count. |
||
146 | * |
||
147 | * @param array $headers |
||
148 | * @return integer |
||
149 | */ |
||
150 | 6 | private function getRetryCount($headers) |
|
163 | |||
164 | } |
||
165 |