Skip to main content

Operations

Operational aspects of a running Error Handling Service (EHS) instance: the dead letter topic, housekeeping, metrics and multi-cluster behaviour.

Dead letter topic​

The EHS uses the regular jEAP messaging error handling for its own consumption. Since it cannot publish its own failures to the error topic it consumes from, every system must order an additional topic, the dead letter topic (DLT). Failed events the EHS cannot process are published there (see Message Flows).

  • Topic naming and permissions: see Getting Started.
  • The maximum message size of the DLT must match the size of the messages processed by the system.
  • Configuration and startup validation: see Kafka configuration.

The dead letter topic should always be empty — messages on it generally mean interrupted business processes. The platform team sets up alerting on the DLT by default when the topic is ordered. If messages end up on the DLT, they can be inspected with a Kafka tool (e.g. Kafdrop): like all failed messages they are wrapped in a MessageProcessingFailedEvent, whose string attributes are directly readable.

The number of messages currently pending on the DLT (end offset minus committed consumer group offset, summed over all partitions) is shown on every page of the UI, so this does not have to be checked through a separate Kafka tool. The count is periodically re-determined and is refreshed immediately once a reactivation run (see below) has finished, see Metrics for the underlying eh_deadletter_pending_messages gauge and GET /api/deadletter/count, which the UI polls.

Kafka connections: the pending message count is determined with a short-lived Kafka consumer per instance and refresh (every 30 seconds by default), see Configuration. Its connections are closed again after each refresh, so they do not add to the permanent connection count of the brokers, but the connection rate grows with the number of instances. On clusters with tight connection or login-rate limits, increase jeap.errorhandling.dead-letter-count.updateFrequencyMillis.

The gauge is calculated by every instance independently, so with several instances each one reports the same value. Aggregate it with max() or avg() rather than sum().

Reactivating dead letter messages​

Once the cause of the failures is fixed, the messages on the DLT can be moved back to the error topic, where the EHS processes them again. Users with the error/retry permission start a reactivation on the Reactivate dead letter messages page of the UI, or with POST /api/deadletter/reactivate?maxRecords=<n> (maxRecords between 1 and 100000; the endpoint responds with 202 Accepted).

  • Run boundary: a run forwards at most maxRecords messages, and only messages that were on the DLT when the run started. Messages arriving on the DLT during a run, e.g. reactivated messages that fail again, are left for the next run.
  • Progress and at-least-once delivery: the messages are forwarded unchanged (key, value and headers). The progress is committed per batch in the consumer group of the EHS (spring.application.name), only after the error topic has acknowledged the forwarded messages. If publishing a message fails, the run stops without committing the batch, so the next run forwards it again. Messages forwarded more than once are recognized by the EHS as duplicates by their idempotence id.
  • Partition loss: if a run loses ownership of partitions with uncommitted progress, it stops with commit-failed and discards its pending offsets rather than overwriting another consumer's progress. The uncommitted messages may be forwarded again by the next owner.
  • Offset retention: while no reactivation runs, the consumer group is not subscribed to the DLT, so the broker would remove the committed progress after its offsets.retention.minutes (7 days by default). The next run would then start at the earliest message on the DLT, and the pending message count would jump back to all retained messages. To prevent this, the EHS commits the existing offsets again, unchanged, once a day (a database lock makes this one instance per day, however often the instances restart) (DeadLetterOffsetKeepAlive, see Scheduled jobs and clustering and Configuration), which restarts the broker's retention timer. The commit is made by a short-lived consumer that joins the consumer group (which also contains the error event listener, so the broker does not accept commits from outside the group), and the error event listener is rebalanced twice per round. The round is skipped while a reactivation run is active, i.e. while a group member is assigned a DLT partition, so it never takes partitions away from a run; the run commits its own offsets. Progress is only lost if the interval is longer than offsets.retention.minutes or the job is disabled; the retention of the DLT itself must also be longer than the time between reactivations, otherwise the messages are gone. Errors that are still stored in the EHS are skipped as duplicates if a run does restart at the earliest message.
  • Concurrent runs: runs started at the same time, on the same or another instance, share the DLT partitions through the consumer group, so no message is forwarded twice. A run that is assigned no DLT partition ends immediately and logs that a concurrent run continues the reactivation.
  • Impact on the error event listener: a run joins and leaves the consumer group once, so the error event listener is rebalanced twice per run, independently of the number of forwarded messages.
  • Stalled runs: a run that cannot make progress for the idle-timeout (default 60 seconds) ends with a warning, see Configuration.

Each run logs its start with the number of pending messages, its progress every 10 seconds, and a summary at its end, for example:

Dead letter reactivation ended (max-records): forwarded 5000 messages from topic ... to topic ... in 1811 ms (2760.9 messages/s)

The end reason is one of max-records, boundary-reached (all messages present at the start forwarded), idle-timeout, concurrent-run, send-failed, commit-failed (consumer group rebalanced while committing) or error (unexpected failure). The same values are used as outcome tag of the eh_deadletter_reactivation_runs metric, see Metrics.

Housekeeping​

A nightly job deletes old errors so the database does not grow indefinitely. Deleted are errors that are older than the configured maximum age and in one of the states TEMPORARY_RETRIED, PERMANENT_RETRIED, DELETED or PERMANENT. Error groups without any remaining errors are deleted as well.

For retention, paging and scheduling properties, see Configuration.

Metrics​

The EHS publishes Micrometer metrics on the error rate and the number of open errors, intended for monitoring and alerting per business application:

MetricTypeDescription
eh_created_temporary_errorsCounterErrors classified as temporary since the start of the instance. Intended as basis for error rate alerting; sum over all instances in multi-instance setups.
eh_created_permanent_errorsCounterErrors classified as permanent since the start of the instance. Intended as basis for error rate alerting; sum over all instances in multi-instance setups.
eh_temporary_retry_pendingGaugeCurrent number of temporary errors with a pending retry (total, from the database).
eh_permanent_openGaugeCurrent number of open permanent errors (manual task pending or open).
eh_permanent_pending_manualtask_createGaugePermanent errors for which no manual task could be created yet (e.g. task service unreachable).
eh_permanent_pending_manualtask_resolveGaugeResolved permanent errors whose manual task could not be closed yet.
eh_permanent_pending_manualtask_deleteGaugeDeleted permanent errors whose manual task could not be deleted yet.
eh_open_errors_by_clusterGaugeCurrent number of errors not in a final state, labelled by the effective Kafka or Modulith publication cluster. Both origins on the same cluster are aggregated. Once a cluster has been seen, it keeps being reported with the value 0.
eh_error_groups_with_open_errorsGaugeCurrent number of error groups with open errors.
eh_deadletter_reactivated_messagesCounterMessages forwarded from the dead letter topic to the error topic and acknowledged by the error topic since the start of the instance. Its rate is the reactivation throughput.
eh_deadletter_reactivation_runsTimerDuration of dead letter reactivation runs, tagged with the reason the run ended (outcome).
eh_deadletter_pending_messagesGaugeMessages currently pending on the dead letter topic (NaN until the first count is determined). Also shown on every page of the UI, see Configuration for the refresh interval.

The gauge sampling interval is described in Configuration.

Scheduled jobs and clustering​

All scheduled jobs use ShedLock with a JDBC lock provider, so they run on exactly one instance in a clustered deployment:

JobPurpose
ResendSchedulerPublishes due scheduled resends back to their original topics.
HouseKeepingSchedulerDeletes old errors and empty error groups.
TasksSynchronizeReconciles the manual task state with Agir (completes pending create/close/delete transitions).
Metrics samplingSamples the gauge metrics from the database.
DeadLetterOffsetKeepAliveCommits the dead letter reactivation's consumer group offsets again so the broker does not expire them.

Multi-cluster support​

The EHS supports multiple Kafka clusters as described in the jEAP messaging documentation, with one particularity: the EHS consumes exclusively from the default cluster. When resending, the target cluster is taken from the stored causing event, so signatures and schema references stay consistent with the original cluster. Failed Modulith publications likewise store the consumed cluster and use that cluster's transactional outbox for retry and discard commands. If a stored cluster has been removed from configuration, the operator action fails without a default-cluster fallback and leaves the error open.

For command targeting and rolling-upgrade requirements, see Target-service headers for Modulith commands.

  • Message Flows — how failures of the EHS itself reach the dead letter topic
  • Configuration — configuration properties and defaults