Class DlqWriter

java.lang.Object
org.alfresco.elasticsearch.batchindexing.DlqWriter

public class DlqWriter extends Object
Writes dead-letter records to a dedicated Elasticsearch index. Best-effort: a DLQ write failure never blocks indexing. ERROR logs on write failure are rate-limited to one per minute per failure-type key to avoid log spam if the DLQ index is broken for a sustained period.
  • Constructor Details

    • DlqWriter

      public DlqWriter(org.opensearch.client.opensearch.OpenSearchClient openSearchClient, String indexName)
  • Method Details

    • ensureIndexExists

      public void ensureIndexExists()
      Best-effort index creation on startup. Logs but does not throw — a broken DLQ must not take down indexing.
    • recordSkip

      public void recordSkip(Long dbId, String nodeRef, Long sourceCommitTimeMs, DeadLetterDocument.FailureStage stage, Throwable throwable)
      Record a give-up event for dbId. If a doc already exists it is upserted in place: firstFailedAt is preserved, lastFailedAt and the failure fields are refreshed, and failureCount is incremented.
      Parameters:
      dbId - node database id; may be null for reader-side skips (rare), in which case no document is written
      nodeRef - best-effort node reference; may be null
      sourceCommitTimeMs - best-effort ACS commit time of the node; may be null
      stage - pipeline stage that produced the skip
      throwable - the exception Spring Batch skipped
    • recordSkip

      public void recordSkip(Long dbId, String nodeRef, Long sourceCommitTimeMs, DeadLetterDocument.FailureStage stage, String failureType, String failureReason)
      Same as recordSkip(Long, String, Long, FailureStage, Throwable) but with the failure classifier / reason supplied as strings. Used by the write-side bulk-item bridge, which receives ES error responses rather than Java exceptions.
    • recordWindowFailure

      public void recordWindowFailure(long tsFromMs, long tsToMs, Throwable cause)
      Record a page-level read failure keyed by the failed time window. The window bounds also form the ES document id (window:<tsFrom>-<tsTo>) so repeated failures on the same window merge into one document; a burst of chunked cycles hitting the same poison rows produces a single DLQ entry with an incrementing failureCount, not N of them.

      dbId is left null (window-level, not node-level) and the message is prefixed with the window bounds so an operator can see the range at a glance.