Kind: Interface
Source: packages/microservices/external/kafka.interface.ts
Part of: Microservices
KafkaJSNumberOfRetriesExceededMetadata describes retry details when a KafkaJS operation exceeds its configured retry limit. It records the number of retry attempts made and the total retry time, allowing error handlers and observability tooling to report retry exhaustion accurately.
Properties
| Property | Type |
|---|---|
retryCount | number |
retryTime | number |
Diagram
mermaidgraph LR A[KafkaJS operation] --> B{Retry attempt fails?} B -->|Yes| C[Increment retryCount] C --> D[Accumulate retryTime] D --> E{Retries exceeded?} E -->|No| A E -->|Yes| F[KafkaJSNumberOfRetriesExceededMetadata] F --> G[Error handling / logging]
Usage
tsimport type { KafkaJSNumberOfRetriesExceededMetadata } from './kafka.interface';
function logRetryExhaustion(
metadata: KafkaJSNumberOfRetriesExceededMetadata,
) {
console.error(
`Kafka retries exhausted after ${metadata.retryCount} attempts ` +
`and ${metadata.retryTime}ms.`,
);
}
const retryMetadata: KafkaJSNumberOfRetriesExceededMetadata = {
retryCount: 5,
retryTime: 12_000,
};
logRetryExhaustion(retryMetadata);
AI Coding Instructions
- Populate
retryCountwith the total number of retry attempts that occurred before failure. - Store
retryTimeas a duration in milliseconds; do not use timestamps or seconds. - Use this interface when handling KafkaJS retry-exhaustion errors to keep logging and error reporting type-safe.
- Avoid mutating retry metadata after it is attached to an error; treat it as a snapshot of the failed operation.
Was this page helpful?