Skip to content

Commit

Permalink
Merge pull request #234 from php-enqueue/queue-consumer-amqp-and-befo…
Browse files Browse the repository at this point in the history
…re-receive-issue

[consumption][amqp] move beforeReceive call at the end of the cycle f…
  • Loading branch information
makasim authored Oct 17, 2017
2 parents b2287c3 + 071f8ca commit 380108f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/enqueue/Consumption/QueueConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ protected function doConsume(ExtensionInterface $extension, Context $context)
$consumer = $context->getPsrConsumer();
$logger = $context->getLogger();

$extension->onBeforeReceive($context);
if (false == $context->getPsrMessage() instanceof AmqpContext) {
$extension->onBeforeReceive($context);
}

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

$extension->onPostReceived($context);

if ($context->getPsrMessage() instanceof AmqpContext) {
$extension->onBeforeReceive($context);
}
} else {
usleep($this->idleTimeout * 1000);
$extension->onIdle($context);
Expand Down

0 comments on commit 380108f

Please sign in to comment.