Skip to content

Commit 37e4204

Browse files
committed
Added the reason in the message publish to RabbitMQ
1 parent 7491939 commit 37e4204

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/Rejection.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
use Bunny\Channel;
88
use Bunny\Client;
99
use Kiboko\Contract\Pipeline\RejectionInterface;
10-
use Kiboko\Contract\Pipeline\StepCodeInterface;
10+
use Kiboko\Contract\Pipeline\RejectionWithReasonInterface;
1111

12-
final readonly class Rejection implements RejectionInterface
12+
final readonly class Rejection implements RejectionInterface, RejectionWithReasonInterface
1313
{
1414
private Channel $channel;
1515

@@ -29,12 +29,6 @@ public function __construct(
2929
);
3030
}
3131

32-
public function teardown(): void
33-
{
34-
$this->channel->close();
35-
$this->connection->stop();
36-
}
37-
3832
public static function withoutAuthentication(
3933
string $stepUuid,
4034
string $host,
@@ -77,10 +71,10 @@ public static function withAuthentication(
7771
return new self($connection, stepUuid: $stepUuid, topic: $topic, exchange: $exchange);
7872
}
7973

80-
public function reject(StepCodeInterface $step, array|object $rejection, ?\Throwable $exception = null): void
74+
public function reject(object|array $rejection, ?\Throwable $exception = null): void
8175
{
8276
$this->channel->publish(
83-
\json_encode([
77+
json_encode([
8478
'item' => $rejection,
8579
'exception' => $exception,
8680
'step' => $this->stepUuid,
@@ -93,11 +87,12 @@ public function reject(StepCodeInterface $step, array|object $rejection, ?\Throw
9387
);
9488
}
9589

96-
public function rejectWithReason(StepCodeInterface $step, array|object $rejection, string $reason, ?\Throwable $exception = null): void
90+
public function rejectWithReason(object|array $rejection, string $reason, ?\Throwable $exception = null): void
9791
{
9892
$this->channel->publish(
99-
\json_encode([
93+
json_encode([
10094
'item' => $rejection,
95+
'reason' => $reason,
10196
'exception' => $exception,
10297
'step' => $this->stepUuid,
10398
], \JSON_THROW_ON_ERROR),
@@ -119,4 +114,10 @@ public function initialize(): void
119114
autoDelete: true,
120115
);
121116
}
117+
118+
public function teardown(): void
119+
{
120+
$this->channel->close();
121+
$this->connection->stop();
122+
}
122123
}

0 commit comments

Comments
 (0)