1 | <?php |
||
25 | class RabbitMqWorker extends BaseSymfonyWorker implements ConsumerInterface |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * Rabbit MQ worker subsystem name. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | const SUBSYSTEM_NAME = "RabbitMqWorker"; |
||
34 | |||
35 | /** |
||
36 | * Reschedule producer instance. |
||
37 | * |
||
38 | * @var ProducerInterface |
||
39 | */ |
||
40 | private $rescheduleProducer; |
||
41 | |||
42 | /** |
||
43 | * Class constructor. |
||
44 | * |
||
45 | * @param EventDispatcherInterface $eventDispatcher Symfony event dispatcher. |
||
46 | * @param ProcessorFactoryInterface $processorFactory |
||
47 | * @param SerializerInterface $serializer |
||
48 | * @param ProducerInterface $rescheduleProducer |
||
49 | * @param LoggerInterface $logger Logger instance. |
||
50 | */ |
||
51 | 7 | public function __construct(EventDispatcherInterface $eventDispatcher, ProcessorFactoryInterface $processorFactory, SerializerInterface $serializer, ProducerInterface $rescheduleProducer, LoggerInterface $logger = null) |
|
57 | |||
58 | /** |
||
59 | * Process single message received from RabbitMq server. |
||
60 | * |
||
61 | * @param AMQPMessage $msg |
||
62 | * |
||
63 | * @return null|integer Return code, dictating further message status. |
||
64 | */ |
||
65 | 7 | public function execute(AMQPMessage $msg) |
|
82 | |||
83 | /** |
||
84 | * @param AMQPMessage $commandData |
||
85 | * {@inheritdoc} |
||
86 | */ |
||
87 | 7 | protected function getSerializedCommandData($commandData) |
|
96 | |||
97 | 7 | public function getSubsystemName() |
|
101 | |||
102 | /** |
||
103 | * Send message for rescheduler, if maximum number of tries has not been exceeded. |
||
104 | * |
||
105 | * @param AMQPMessage $msg |
||
106 | * @param Exception $e |
||
107 | * @param CommandProcessorInterface $processor |
||
108 | */ |
||
109 | 6 | private function maybeReschedule(AMQPMessage $msg, Exception $e, CommandProcessorInterface $processor = null) |
|
131 | |||
132 | /** |
||
133 | * Get retry count. |
||
134 | * |
||
135 | * @param array $headers |
||
136 | * @return integer |
||
137 | */ |
||
138 | 6 | private function getRetryCount($headers) |
|
151 | } |
||
152 |