Skip to content

Commit

Permalink
Basic nack failed messages without requeue
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHash committed Aug 22, 2020
1 parent a3dc518 commit c299663
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
16 changes: 8 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/Job/RabbitMq3Worker.php
Expand Up @@ -70,6 +70,7 @@ public function run(array $parameters = []): void
private function execute(AMQPMessage $amqpMessage): void
{
$deliveryInfo = $amqpMessage->delivery_info;
/** @var AMQPChannel $channel */
$channel = $deliveryInfo['channel'];
$deliveryTag = $deliveryInfo['delivery_tag'];

Expand All @@ -84,6 +85,7 @@ private function execute(AMQPMessage $amqpMessage): void

try {
$this->messageBus->receive($envelope);
$channel->basic_ack($deliveryTag);
} catch (RuntimeException $error) {
/** @var JobDefinitionInterface $job */
$job = $this->jobDefinitionMap->get($jobKey);
Expand All @@ -97,8 +99,7 @@ private function execute(AMQPMessage $amqpMessage): void
//@todo add message/metadata to error context
$this->logger->error($error->getMessage(), ['exception' => $error->getTrace()]);
}
$channel->basic_nack($deliveryTag, false, false);
}

$channel->basic_ack($deliveryTag);
}
}

0 comments on commit c299663

Please sign in to comment.