Skip to content

Commit b74c606

Browse files
committed
Added the reason in the message publish to RabbitMQ
1 parent 3e16e14 commit b74c606

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/Rejection.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
use Bunny\Channel;
88
use Bunny\Client;
99
use Kiboko\Contract\Pipeline\RejectionInterface;
10+
use Kiboko\Contract\Pipeline\RejectionWithReasonInterface;
1011

11-
final readonly class Rejection implements RejectionInterface
12+
final readonly class Rejection implements RejectionInterface, RejectionWithReasonInterface
1213
{
1314
private Channel $channel;
1415

@@ -86,6 +87,23 @@ public function reject(object|array $rejection, ?\Throwable $exception = null):
8687
);
8788
}
8889

90+
public function rejectWithReason(object|array $rejection, string $reason, ?\Throwable $exception = null): void
91+
{
92+
$this->channel->publish(
93+
json_encode([
94+
'item' => $rejection,
95+
'reason' => $reason,
96+
'exception' => $exception,
97+
'step' => $this->stepUuid,
98+
], \JSON_THROW_ON_ERROR),
99+
[
100+
'content-type' => 'application/json',
101+
],
102+
$this->exchange,
103+
$this->topic,
104+
);
105+
}
106+
89107
public function initialize(): void
90108
{
91109
$this->channel->queueDeclare(

0 commit comments

Comments
 (0)