Skip to content

Commit 380108f

Browse files
authored
Merge pull request #234 from php-enqueue/queue-consumer-amqp-and-before-receive-issue
[consumption][amqp] move beforeReceive call at the end of the cycle f…
2 parents b2287c3 + 071f8ca commit 380108f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/enqueue/Consumption/QueueConsumer.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,9 @@ protected function doConsume(ExtensionInterface $extension, Context $context)
263263
$consumer = $context->getPsrConsumer();
264264
$logger = $context->getLogger();
265265

266-
$extension->onBeforeReceive($context);
266+
if (false == $context->getPsrMessage() instanceof AmqpContext) {
267+
$extension->onBeforeReceive($context);
268+
}
267269

268270
if ($context->isExecutionInterrupted()) {
269271
throw new ConsumptionInterruptedException();
@@ -307,6 +309,10 @@ protected function doConsume(ExtensionInterface $extension, Context $context)
307309
$logger->info(sprintf('Message processed: %s', $context->getResult()));
308310

309311
$extension->onPostReceived($context);
312+
313+
if ($context->getPsrMessage() instanceof AmqpContext) {
314+
$extension->onBeforeReceive($context);
315+
}
310316
} else {
311317
usleep($this->idleTimeout * 1000);
312318
$extension->onIdle($context);

0 commit comments

Comments
 (0)