-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRejectOperation.php
45 lines (38 loc) · 1.07 KB
/
RejectOperation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
declare(strict_types=1);
namespace Cdn77\RabbitMQBundle\RabbitMQ\Operation;
use Bunny\Message;
use Cdn77\RabbitMQBundle\RabbitMQ\Connection;
final class RejectOperation
{
/** @var Connection */
private $connection;
public function __construct(Connection $connection)
{
$this->connection = $connection;
}
public function handle(Message $message, bool $requeue = true): void
{
$channel = $this->connection->getChannel();
$channel->getClient()->nack(
$channel->getChannelId(),
$message->deliveryTag,
false,
$requeue
);
}
/**
* RabbitMQ will reject all outstanding delivery tags
* up to and including the tag specified in the not nacknowledgement
*/
public function handleAll(Message $lastMessage, bool $requeue = true): void
{
$channel = $this->connection->getChannel();
$channel->getClient()->nack(
$channel->getChannelId(),
$lastMessage->deliveryTag,
true,
$requeue
);
}
}