Dbal Dead Letter
Ecotone comes with full support for managing full life cycle of a error message by using .
Store failed Message with all details about the exception
Allow for reviewing error Messages
Allow for deleting and replaying error Message back to the
Installation
Set up Error Channel like discussed at the
Send Error Messages directly to Dead Letter:
If we configure default error channel to point to "dbal_dead_letter" then all Error Messages will land there directly:
Symfony Laravel Lite
config/packages/ecotone.yaml
Copy ecotone:
defaultErrorChannel: "dbal_dead_letter"
config/ecotone.php
Copy return [
'defaultErrorChannel' => 'dbal_dead_letter',
];
Copy $ecotone = EcotoneLite::bootstrap(
configuration: ServiceConfiguration::createWithDefaults()
->withDefaultErrorChannel('dbal_dead_letter')
);
Try to recover with Retries first
We may also want to try to recover before we consider Message to be stored in Dead Letter:
Symfony Laravel Lite
config/packages/ecotone.yaml
Copy ecotone:
defaultErrorChannel: "errorChannel"
config/ecotone.php
Copy return [
'defaultErrorChannel' => 'errorChannel',
];
Copy $ecotone = EcotoneLite::bootstrap(
configuration: ServiceConfiguration::createWithDefaults()
->withDefaultErrorChannel('errorChannel')
);
and then we use inbuilt Retry Strategy:
Copy #[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"
);
}
Dead Letter Console Commands
Help
Get more details about existing commands
Symfony Laravel
Copy bin/console ecotone:deadletter:help
Copy artisan ecotone:deadletter:help
Listing Error Messages
Listing current error messages
Symfony Laravel Lite
Copy bin/console ecotone:deadletter:list
Copy artisan ecotone:deadletter:list
Copy $list = $messagingSystem->runConsoleCommand("ecotone:deadletter:list", []);
Show Details About Error Message
Get more details about given error message
Symfony Laravel Lite
Copy bin/console ecotone:deadletter:show {messageId}
Copy artisan ecotone:deadletter:show {messageId}
Copy $details = $messagingSystem->runConsoleCommand("ecotone:deadletter:show", ["messageId" => $messageId]);
Replay Error Message
Replay error message. It will return to previous channel for consumer to pick it up and handle again.
Symfony Laravel Lite
Copy bin/console ecotone:deadletter:replay {messageId}
Copy artisan ecotone:deadletter:replay {messageId}
Copy $messagingSystem->runConsoleCommand("ecotone:deadletter:replay", ["messageId" => $messageId]);
Replay All Messages
Replaying all the error messages.
Symfony Laravel Lite
Copy bin/console ecotone:deadletter:replayAll
Copy artisan ecotone:deadletter:replayAll
Copy $messagingSystem->runConsoleCommand("ecotone:deadletter:replayAll", []);
Delete Message
Delete given error message
Symfony Laravel Lite
Copy bin/console ecotone:deadletter:delete {messageId}
Copy artisan ecotone:deadletter:delete {messageId}
Copy $messagingSystem->runConsoleCommand("ecotone:deadletter:delete", ["messageId" => $messageId]);
Turn off Dbal Dead Letter
Copy #[ServiceContext]
public function dbalConfiguration()
{
return DbalConfiguration::createWithDefaults()
->withDeadLetter(false);
}
Managing Multiple Ecotone Applications
This is especially useful when we've multiple Applications, so we can go to single place and see if any Application have failed to process Message.