Error Channel and Dead Letter
Error Channel
Ecotone
comes with solution called Error Channel.
Error Channel is a place where unrecoverable Errors can go, this way we can preserve Error Messages even if we can't handle anyhow.
Error Channel may log those Messages, store them in database, push them to some Asynchronous Channel. The what is to be done is flexibile and can be adjusted to Application needs.
Configuration
Error Channel can be configured per Message Consumer, or globally as default Error Channel for all Message Consumers:
- Symfony
- Laravel
- Lite
config/packages/ecotone.yaml
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 as long as Error Handler does not throw exception.
Manual Handling
To handle incoming Error Messages, we can bind to our defined Error Channel using ServiceActivator:
Service Activator are endpoints like Command Handlers, however they are not exposed using Command/Event/Query Buses. You may use them for internal handling.
Delayed Retries
We can also use inbuilt retry mechanism, that will be resend Error Message to it's original Message Channel with delay. If our Default Error Channel is configured for name "errorChannel", then we can connect it like bellow:
Discarding all Error Messages
If for some cases we want to discard Error Messages, we can set up error channel to default inbuilt one called "nullChannel". That may be used in combination of retries, if after given attempt Message is still not handled, then discard:
Dbal Dead Letter
Ecotone comes with full support for managing full life cycle of a error message. Read more in next section.
Last updated