Message Flows
This page shows the runtime behaviour of the Error Handling Service (EHS) as sequence diagrams. See Architecture for the static structure and the error state model.
Failed message intake
When message processing fails in a business service, the jEAP messaging error handler publishes a
MessageProcessingFailedEvent to the error topic and acknowledges the original message, so the consumer
is not blocked. The EHS consumes the failed event, persists the error together with the original message
bytes, and classifies it.
Failures during intake follow the EHS error-handling flow.
Failed Modulith publication intake
A service using the Modulith error handling starter publishes a
ModulithPublicationProcessingFailedEvent to the dedicated Modulith publication failure topic after the publication
exhausts its local retry budget. The EHS
persists the publication ID, listener, internal event payload, consumed Kafka cluster, and the source service's retry
and discard command topics. Exception messages and stack traces are made safe for PostgreSQL text columns before they
are stored, and unavailable tracing information does not prevent the failure from being recorded.
The temporality reported in the failure event decides what happens next, exactly as it does for a
MessageProcessingFailedEvent:
PERMANENT— the publication is recorded as a permanent error and escalated to a manual task. It is only retried when someone triggers the retry in the UI.TEMPORARY— the publication is recorded as a temporary error and retried automatically by the resend scheduler, which queues aRetryModulithPublicationCommandinstead of republishing a message. Once theResendingStrategystops retrying, the error is escalated to a permanent one.
A retry queues RetryModulithPublicationCommand; closing the
error queues DiscardModulithPublicationCommand. Both commands are inserted into the transactional outbox for that
same Kafka cluster in the same transaction as the EHS state change. If the cluster is no longer configured, the action
fails and the EHS error remains open rather than silently sending the command through the default cluster.
Automatic retry of temporary errors
The message is republished to the cluster it was originally consumed from (see
Operations). The header jeap_eh_target_service allows other
consumers of the same topic to ignore messages that are resent for a different service.
For a temporary Modulith publication error the scheduler follows the same
loop, but instead of republishing a message it queues a RetryModulithPublicationCommand for the publishing
application through the transactional outbox. If the publication fails again, that application reports it as a new
failure event for the same publication, so the ResendingStrategy counts the attempts and eventually escalates the
publication to a permanent error.
Manual retry and delete from the UI
Operators with the corresponding roles can manually resend or close permanent errors in the UI. Both actions are recorded in the audit log with the acting user from the JWT token. Kafka errors resend the stored causing message. Modulith errors publish a UUID-exact command through the transactional outbox.
For Modulith publications, the command references the ID of the consumed publication failure event. If command
enqueueing fails, the database transaction rolls back and the error remains open. If Agir is unavailable, the state
remains at RESOLVE_ON_MANUALTASK / DELETE_ON_MANUALTASK and a later TasksSynchronize run retries the close.
Error handling of the Error Handling Service itself
So that no message is lost even when the EHS fails, the EHS uses the regular jEAP messaging error handling
for its own consumption — but publishing to its own error topic would create a loop. The EHS therefore
publishes fatal processing failures to a dedicated dead letter topic. The typed listeners classify
database availability, lock and read-only transaction problems as RecoverableEhsProcessingException
and retry consumption with a configurable back-off.
FatalEhsProcessingException routes the event to the dead letter topic:
Modulith command targeting
Retry and discard commands use the target-service headers configured by EHS. That reference also covers legacy delivery and rolling upgrades. The Kafka cluster and topic determine delivery; publication UUID and failure-event identity determine which failed generation can be retried or discarded.
Related
- Architecture — error state model and data model
- Configuration — resend strategy and retry properties
- Operations — dead letter topic monitoring, housekeeping, metrics