Error Channel and Dead Letter
Ecotone
comes with solution that allow to push Error Messages to error channel
.
Depending on what subscribing to error channel you may provide different behaviour.
From logging, storing or even discarding the message.The error channel is channel defined for handling failed messages. As a default it's turned off.
We may set up error channel for specific consumer
Setting up Error Channel means that Message Consumer will send Error Message to error channel and then continue handling next messages.
After sending Error Message to error channel, message is considered handled.
After setting it up default error channel to "errorChannel" we may subscribe to the errors by setting up ServiceActivator:
#[ServiceActivator("errorChannel")]
public function handle(ErrorMessage $errorMessage): void
{
// do something with ErrorMessage
}
Service Activator are endpoints like Command Handlers, however they are not exposed using Command/Event/Query Buses.
You may use them for internal handling.
Ecotone comes with full support for managing full life cycle of a error message by using Dbal Module.
- Store failed Message with all details about the exception
- Allow for reviewing error Messages
- Set up "errorChannel" in ErrorHandlerConfiguration to "dbal_dead_letter"
#[ServiceContext]
public function errorConfiguration()
{
return ErrorHandlerConfiguration::createWithDeadLetterChannel(
"errorChannel",
// your retry strategy
RetryTemplateBuilder::exponentialBackoff(1000, 10)
->maxRetryAttempts(3),
// if retry strategy will not recover, then send here
"dbal_dead_letter"
);
}
If you would set up "nullChannel" in place of "dbal_dead_letter", then all Message that can't be retried with success would be discared.
Get more details about existing commands
Symfony
Laravel
bin/console ecotone:deadletter:help
artisan ecotone:deadletter:help
Listing current error messages
Symfony
Laravel
Lite
bin/console ecotone:deadletter:list
artisan ecotone:deadletter:list
$list = $messagingSystem->runConsoleCommand("ecotone:deadletter:list", []);
Get more details about given error message
Symfony
Laravel
Lite
bin/console ecotone:deadletter:show {messageId}
artisan ecotone:deadletter:show {messageId}
$details = $messagingSystem->runConsoleCommand("ecotone:deadletter:show", ["messageId" => $messageId]);
Replay error message. It will return to previous channel for consumer to pick it up and handle again.
Symfony
Laravel
Lite
bin/console ecotone:deadletter:replay {messageId}
artisan ecotone:deadletter:replay {messageId}
$messagingSystem->runConsoleCommand("ecotone:deadletter:replay", ["messageId" => $messageId]);
Replaying all the error messages.
Symfony
Laravel
Lite
bin/console ecotone:deadletter:replayAll
artisan ecotone:deadletter:replayAll
$messagingSystem->runConsoleCommand("ecotone:deadletter:replayAll", []);
Delete given error message
Symfony
Laravel
Lite
bin/console ecotone:deadletter:delete {messageId}
artisan ecotone:deadletter:delete {messageId}
$messagingSystem->runConsoleCommand("ecotone:deadletter:delete", ["messageId" => $messageId]);
#[ServiceContext]
public function dbalConfiguration()
{
return DbalConfiguration::createWithDefaults()
->withDeadLetter(false);
}
Last modified 2mo ago