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 | * Reschedule producer instance. |
||
38 | * |
||
39 | * @var ProducerInterface |
||
40 | */ |
||
41 | private $rescheduleProducer; |
||
42 | |||
43 | /** |
||
44 | * Class constructor. |
||
45 | * |
||
46 | * @param EventDispatcherInterface $eventDispatcher Symfony event dispatcher. |
||
47 | * @param ProcessorFactoryInterface $processorFactory |
||
48 | * @param Serializer $serializer |
||
49 | * @param ProducerInterface $rescheduleProducer |
||
50 | * @param LoggerInterface $logger Logger instance. |
||
51 | */ |
||
52 | 8 | public function __construct(EventDispatcherInterface $eventDispatcher, ProcessorFactoryInterface $processorFactory, Serializer $serializer, ProducerInterface $rescheduleProducer, LoggerInterface $logger = null) |
|
59 | |||
60 | /** |
||
61 | * Process single message received from RabbitMq server. |
||
62 | * |
||
63 | * @param AMQPMessage $msg |
||
64 | * |
||
65 | * @return null|integer Return code, dictating further message status. |
||
66 | */ |
||
67 | 8 | public function execute(AMQPMessage $msg) |
|
84 | |||
85 | /** |
||
86 | * @param AMQPMessage $commandData |
||
87 | * {@inheritdoc} |
||
88 | */ |
||
89 | 8 | protected function getSerializedCommandData($commandData) |
|
98 | |||
99 | 8 | public function getSubsystemName() |
|
103 | |||
104 | /** |
||
105 | * Send message for rescheduler, if maximum number of tries has not been exceeded. |
||
106 | * |
||
107 | * @param AMQPMessage $msg |
||
108 | * @param Exception $e |
||
109 | * @param CommandProcessorInterface $processor |
||
110 | */ |
||
111 | 7 | private function maybeReschedule(AMQPMessage $msg, Exception $e, CommandProcessorInterface $processor = null) |
|
133 | |||
134 | /** |
||
135 | * Get retry count. |
||
136 | * |
||
137 | * @param array $headers |
||
138 | * @return integer |
||
139 | */ |
||
140 | 7 | private function getRetryCount($headers) |
|
153 | } |
||
154 |