Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Ecotone\Dbal\Recoverability;

use Ecotone\Api\Attribute\ConsoleParameterOption;
use Ecotone\Api\Console\ConsoleCommandResultSet;
use Ecotone\Api\Dbal\Gateway\DeadLetterGateway;
use Ecotone\Api\Messaging\ErrorContext;
Expand All @@ -21,8 +22,8 @@ public function help(): ConsoleCommandResultSet
[
[DbalDeadLetterModule::LIST_COMMAND_NAME . ' {page:int}', 'List all dead messages'],
[DbalDeadLetterModule::SHOW_COMMAND_NAME . ' {messageId:string} {fullDetails:bool}', 'Show more details about specific message'],
[DbalDeadLetterModule::REPLAY_COMMAND_NAME . ' {messageId:string} {targetChannel:?string}', 'Replay chosen dead message, to its source channel or to the target channel'],
[DbalDeadLetterModule::REPLAY_ALL_COMMAND_NAME . ' {targetChannel:?string}', 'Replay ALL dead messages, to their source channels or to the target channel'],
[DbalDeadLetterModule::REPLAY_COMMAND_NAME . ' {messageId:string} {--targetChannel=}', 'Replay chosen dead message, to its source channel or to the target channel'],
[DbalDeadLetterModule::REPLAY_ALL_COMMAND_NAME . ' {--targetChannel=}', 'Replay ALL dead messages, to their source channels or to the target channel'],
[DbalDeadLetterModule::DELETE_COMMAND_NAME . ' {messageId:string}', 'Delete chosen dead message'],
]
);
Expand Down Expand Up @@ -65,7 +66,7 @@ public function show(DeadLetterGateway $deadLetterGateway, string $messageId, bo
);
}

public function replay(DeadLetterGateway $deadLetterGateway, string $messageId, ?string $targetChannel = null): void
public function replay(DeadLetterGateway $deadLetterGateway, string $messageId, #[ConsoleParameterOption] ?string $targetChannel = null): void
{
$deadLetterGateway->replay($messageId, $targetChannel);
}
Expand All @@ -75,7 +76,7 @@ public function delete(DeadLetterGateway $deadLetterGateway, string $messageId):
$deadLetterGateway->delete($messageId);
}

public function replayAll(DeadLetterGateway $deadLetterGateway, ?string $targetChannel = null): void
public function replayAll(DeadLetterGateway $deadLetterGateway, #[ConsoleParameterOption] ?string $targetChannel = null): void
{
$deadLetterGateway->replayAll($targetChannel);
}
Expand Down
8 changes: 8 additions & 0 deletions packages/Dbal/tests/Integration/DeadLetterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ public function test_all_dead_letter_messages_are_replayed_to_the_chosen_channel
$handler = new class () {
public const TARGET_CHANNEL = 'allTargetChannel';

public int $sourceInvocations = 0;
/** @var string[] */
public array $handledByTarget = [];
private bool $hasEmitted = false;
Expand All @@ -378,6 +379,8 @@ public function emit(): ?string
#[\Ecotone\Api\Attribute\InternalHandler('allSourceChannel')]
public function handleBySource(string $payload): void
{
$this->sourceInvocations++;

throw new RuntimeException('simulated');
}

Expand Down Expand Up @@ -410,6 +413,7 @@ classesToResolve: [$handler::class],
$ecotone->getGateway(DeadLetterGateway::class)->replayAll($handler::TARGET_CHANNEL);

$this->assertErrorMessageCount($ecotone, 0);
$this->assertSame(1, $handler->sourceInvocations);
$this->assertSame(['payload'], $handler->handledByTarget);
}

Expand Down Expand Up @@ -483,6 +487,7 @@ public function test_console_command_replays_dead_letter_message_to_the_chosen_c
$handler = new class () {
public const TARGET_CHANNEL = 'consoleTargetChannel';

public int $sourceInvocations = 0;
/** @var string[] */
public array $handledByTarget = [];
private bool $hasEmitted = false;
Expand All @@ -502,6 +507,8 @@ public function emit(): ?string
#[\Ecotone\Api\Attribute\InternalHandler('consoleSourceChannel')]
public function handleBySource(string $payload): void
{
$this->sourceInvocations++;

throw new RuntimeException('simulated');
}

Expand Down Expand Up @@ -535,6 +542,7 @@ classesToResolve: [$handler::class],
$ecotone->runConsoleCommand('ecotone:deadletter:replay', ['messageId' => $messageId, 'targetChannel' => $handler::TARGET_CHANNEL]);

$this->assertErrorMessageCount($ecotone, 0);
$this->assertSame(1, $handler->sourceInvocations);
$this->assertSame(['payload'], $handler->handledByTarget);
}

Expand Down
Loading