@babelqueue/pulsar 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -20,7 +20,7 @@ import { Envelope, HeaderCarrier, IncomingEnvelope } from '@babelqueue/core';
20
20
  * });
21
21
  * const consumer = new PulsarConsumer(sub, {
22
22
  * "urn:babel:orders:created": async (env) => { ... },
23
- * });
23
+ * }, { subscriptionType: "Shared" }); // declare it (or pass `client` together with `topic`): see PulsarConsumerOptions
24
24
  * await consumer.run();
25
25
  *
26
26
  * This implements §5 of the broker-bindings contract: the canonical envelope is the message
@@ -28,9 +28,23 @@ import { Envelope, HeaderCarrier, IncomingEnvelope } from '@babelqueue/core';
28
28
  * `bq-trace-id` = trace_id, `bq-message-id` = meta.id, plus `bq-schema-version` /
29
29
  * `bq-source-lang` / `bq-attempts`. The envelope is unchanged (`schema_version` stays 1);
30
30
  * Pulsar is purely additive. A failed handler `negativeAcknowledge`s the message, so it is
31
- * redelivered (at-least-once) and `getRedeliveryCount()` is incremented; the authoritative
32
- * attempt count is the body's `bq-attempts`, reconciled to `max(bq-attempts,
33
- * getRedeliveryCount())` — no −1, because Pulsar's redelivery count is 0-based.
31
+ * redelivered (at-least-once) and `getRedeliveryCount()` is incremented — up to `maxAttempts`
32
+ * deliveries (default 3, ADR-0036): the message that exhausts them is written to `<queue>.dlq`
33
+ * (when a `deadLetterProducer` is given) or acknowledged and dropped. A body that does not decode
34
+ * into an envelope (including an object with no valid identity) is poison: it never reaches a
35
+ * handler, and with dead-lettering on it is recorded in `<queue>.dlq` in the ADR-0035 shape without
36
+ * retry. Per §5.2 / §5.7 the
37
+ * consumer routes on the `bq-job` property (the body's URN is used only when the property is
38
+ * absent or blank) and takes `attempts` from the authoritative `bq-attempts` property (the
39
+ * body's value is used only when the property is absent or not a plain ASCII-decimal integer
40
+ * that fits a 32-bit int), reconciled to `max(bq-attempts, getRedeliveryCount())` — no −1,
41
+ * because Pulsar's redelivery count is 0-based. The handler still receives the body's envelope.
42
+ *
43
+ * **Version gate (§5.7 step 3).** Before the body is decoded the consumer reads the
44
+ * `bq-schema-version` property. A missing or blank value (empty or only ASCII whitespace) changes nothing; any value other than
45
+ * the core's supported `SCHEMA_VERSION` (`"2"`, `"x"`, `"01"`, ...) rejects the message undecoded
46
+ * through the same path as a non-conformant envelope — `onError` (with an error naming the
47
+ * version, and an empty envelope since nothing was decoded) and a `negativeAcknowledge`.
34
48
  *
35
49
  * **Out-of-band headers (ADR-0028).** A `headers` carrier (e.g. a W3C `traceparent` for cross-hop
36
50
  * span linkage) rides as additional native Pulsar **message properties** beside the contract `bq-*`
@@ -70,10 +84,27 @@ interface PulsarReceivedMessage {
70
84
  * satisfies it structurally; a fake satisfies it in tests.
71
85
  */
72
86
  interface PulsarConsumerClient {
87
+ /**
88
+ * The topic the subscription reads. pulsar-client's `Consumer` has **no** such method (only its `Producer`
89
+ * does), so with it the topic comes from the {@link PulsarConsumerOptions.topic} option; a custom
90
+ * subscription wrapper may provide this to make `topic` unnecessary.
91
+ */
92
+ getTopic?(): string;
73
93
  receive(timeoutMs?: number): Promise<PulsarReceivedMessage>;
74
94
  acknowledge(message: PulsarReceivedMessage): Promise<void> | void;
75
95
  negativeAcknowledge(message: PulsarReceivedMessage): Promise<void> | void;
76
96
  }
97
+ /**
98
+ * The subset of the Pulsar client this adapter calls to build its own retry producer. A `Client` from
99
+ * `pulsar-client` satisfies it structurally.
100
+ */
101
+ interface PulsarClientLike {
102
+ createProducer(config: {
103
+ topic: string;
104
+ }): Promise<PulsarProducer>;
105
+ }
106
+ /** The subscription type, as pulsar-client names it (`Key_Shared` is accepted as an alias of `KeyShared`). */
107
+ type PulsarSubscriptionType = "Exclusive" | "Shared" | "Failover" | "KeyShared" | "Key_Shared";
77
108
  /**
78
109
  * Project the envelope's contract fields onto native Pulsar message properties
79
110
  * (string→string): `bq-job` = URN, `bq-trace-id` = trace_id, `bq-message-id` = meta.id, plus
@@ -137,24 +168,125 @@ interface PulsarConsumerOptions {
137
168
  onError?: (error: unknown, envelope: IncomingEnvelope, message: PulsarReceivedMessage) => void;
138
169
  /** Per-receive timeout in ms (default 1000). A timeout yields an empty poll, not an error. */
139
170
  receiveTimeoutMs?: number;
171
+ /**
172
+ * Optional diagnostic hook, called when the `bq-job` property and the body's URN differ (the
173
+ * property wins and the message is routed on it). `envelope` is the body's envelope. Separate
174
+ * from {@link PulsarConsumerOptions.onError}: it is not an error, and anything it throws (or
175
+ * rejects with) is swallowed — it never changes how the message is handled or acknowledged.
176
+ */
177
+ onRoutingMismatch?: (propertyUrn: string, bodyUrn: string, envelope: IncomingEnvelope) => unknown;
178
+ /**
179
+ * The total number of deliveries a message gets, the first included (default 3; `1` = no retry;
180
+ * ADR-0036 decision 1). A failing handler, an unmapped URN without {@link onUnknownUrn} and a poison
181
+ * body with dead-lettering off are retried (`negativeAcknowledge`) while `reconciled attempts + 1`
182
+ * is below it; the delivery that reaches it is dead-lettered (when {@link deadLetterProducer} is
183
+ * set) or acknowledged and dropped. Must be an integer of at least 1.
184
+ */
185
+ maxAttempts?: number;
186
+ /**
187
+ * A producer on the dead-letter topic (by convention `<queue>.dlq`). Dead-lettering is on exactly
188
+ * when it is set; the SDK does not use Pulsar's native `DeadLetterPolicy`. The original message is
189
+ * acknowledged only after the record was sent; a failed send leaves it negatively acknowledged so
190
+ * it is redelivered and the write is tried again.
191
+ */
192
+ deadLetterProducer?: PulsarProducer;
193
+ /**
194
+ * A producer on the consumer's **own** topic. A retry re-publishes the message to that topic with
195
+ * `bq-attempts` (and the body's `attempts`) raised to the counted value and then acknowledges the
196
+ * original — the Go model. The count then lives in the message itself, so the bound holds on every
197
+ * subscription type. Optional when {@link client} is given (the consumer builds the producer itself);
198
+ * a failed re-publish leaves the original negatively acknowledged (never lost).
199
+ *
200
+ * Without a producer or a client a retry is a `negativeAcknowledge`, which advances the native
201
+ * redelivery count only on `Shared` / `Key_Shared`: on `Exclusive` / `Failover` it stays 0 and the retry
202
+ * would never reach `maxAttempts`, so that combination is rejected at construction (see
203
+ * {@link subscriptionType}).
204
+ */
205
+ retryProducer?: PulsarProducer;
206
+ /**
207
+ * The Pulsar client the consumer builds its retry producer from, lazily on the first retry, on
208
+ * {@link topic}. Needs `topic` (pulsar-client's `Consumer` cannot tell its topic). Ignored when
209
+ * {@link retryProducer} is given.
210
+ */
211
+ client?: PulsarClientLike;
212
+ /**
213
+ * The topic the retry producer is created on — the topic the consumer reads. Required together with
214
+ * {@link client} (a pulsar-client `Consumer` has no `getTopic()`); a subscription wrapper that provides
215
+ * `getTopic()` makes it optional.
216
+ */
217
+ topic?: string;
218
+ /**
219
+ * The subscription type the consumer was created with. `Exclusive` and `Failover` cannot bound a
220
+ * nack-driven retry (a negative acknowledgement does not advance the redelivery count there), so with
221
+ * `maxAttempts > 1` they require a {@link retryProducer} or a {@link client}. **Not declaring it counts as
222
+ * `Exclusive`** (pulsar-client's own default, and the fail-closed choice): without a `retryProducer` or a
223
+ * `client` the constructor throws `BabelQueueError`. Declare `"Shared"` or `"Key_Shared"` to keep the
224
+ * `negativeAcknowledge` retry without a producer.
225
+ */
226
+ subscriptionType?: PulsarSubscriptionType;
227
+ /**
228
+ * The queue name written to `dead_letter.original_queue` of a poison record (a decodable envelope
229
+ * uses its own `meta.queue`). Defaults to the {@link deadLetterProducer} topic without its `.dlq`
230
+ * suffix.
231
+ */
232
+ queue?: string;
233
+ /** Receives the "message dropped" and "dead-letter write failed" warnings (default `console.warn`). */
234
+ onWarn?: (message: string) => void;
140
235
  }
236
+ /** Default total number of deliveries (ADR-0036 decision 1). */
237
+ declare const DEFAULT_MAX_ATTEMPTS = 3;
141
238
  /**
142
239
  * Receives from a Pulsar subscription, decodes + validates each message, routes it to the
143
240
  * handler for its URN, and acknowledges it on success. A throwing handler
144
241
  * `negativeAcknowledge`s the message — the broker redelivers it and increments
145
- * `getRedeliveryCount()` (at-least-once); `attempts` is reconciled to
146
- * `max(bq-attempts, getRedeliveryCount())` for the handler.
242
+ * `getRedeliveryCount()` (at-least-once; with a `retryProducer` the message is instead re-published with
243
+ * `bq-attempts` + 1, which also bounds `Exclusive` / `Failover` subscriptions) — until `maxAttempts` deliveries are used up; the last one is
244
+ * dead-lettered to `<queue>.dlq` or acknowledged and dropped (ADR-0036). Routing uses the `bq-job`
245
+ * property (body URN as the fallback); `attempts` is the `bq-attempts` property (body value as the
246
+ * fallback) reconciled to `max(.., getRedeliveryCount())` for the handler.
147
247
  */
148
248
  declare class PulsarConsumer {
149
249
  private readonly consumer;
150
250
  private readonly handlers;
151
251
  private readonly options;
252
+ private readonly maxAttempts;
253
+ private builtRetryProducer;
254
+ private readonly warn;
152
255
  constructor(consumer: PulsarConsumerClient, handlers: BabelHandlers, options?: PulsarConsumerOptions);
256
+ /**
257
+ * Setup check: on `Exclusive` / `Failover` (and an undeclared type) a negative acknowledgement does not advance the native
258
+ * redelivery count, so a retry needs a re-publish. Fail loudly here instead of looping at run time.
259
+ */
260
+ private checkRetryBound;
261
+ private retryTopic;
262
+ /** The retry producer: the one given, else one built (once) from the client; undefined when neither exists. */
263
+ private resolveRetryProducer;
153
264
  /** Receive one message (up to the receive timeout), route + settle it. Returns 1, or 0 on timeout. */
154
265
  poll(): Promise<number>;
155
266
  /** Poll until `signal` aborts. */
156
267
  run(signal?: AbortSignal): Promise<void>;
157
268
  private handle;
269
+ /**
270
+ * The settle decision of a retryable outcome (ADR-0036 decisions 1 and 2). `counted` is the reconciled
271
+ * attempts plus one for this delivery. A poison body with dead-lettering on is recorded without retry;
272
+ * every other outcome retries (`negativeAcknowledge`: the native redelivery count advances, so the
273
+ * next delivery counts one more) while `counted < maxAttempts`, then dead-letters or drops.
274
+ */
275
+ private settle;
276
+ /**
277
+ * Retry one delivery. With a {@link PulsarConsumerOptions.retryProducer}: re-publish to the consumer's
278
+ * own topic carrying `bq-attempts = counted` (reconcile = max(bq-attempts, RedeliveryCount) on the next
279
+ * delivery), then acknowledge the original — only after the send succeeded. Otherwise `negativeAcknowledge`.
280
+ */
281
+ private retry;
282
+ private retryMessage;
283
+ /**
284
+ * Write the DLQ record, then acknowledge the original — only after the send succeeded. A failed send
285
+ * leaves the original negatively acknowledged, so it is redelivered and the write is tried again.
286
+ */
287
+ private deadLetter;
288
+ private deadLetterMessage;
289
+ private notifyRoutingMismatch;
158
290
  }
159
291
 
160
- export { type BabelHandler, type BabelHandlers, type PublishOptions, PulsarConsumer, type PulsarConsumerClient, type PulsarConsumerOptions, type PulsarProducer, type PulsarProducerMessage, PulsarPublisher, type PulsarReceivedMessage, headersOf, pulsarProperties, toPulsarMessage };
292
+ export { type BabelHandler, type BabelHandlers, DEFAULT_MAX_ATTEMPTS, type PublishOptions, type PulsarClientLike, PulsarConsumer, type PulsarConsumerClient, type PulsarConsumerOptions, type PulsarProducer, type PulsarProducerMessage, PulsarPublisher, type PulsarReceivedMessage, type PulsarSubscriptionType, headersOf, pulsarProperties, toPulsarMessage };
package/dist/index.d.ts CHANGED
@@ -20,7 +20,7 @@ import { Envelope, HeaderCarrier, IncomingEnvelope } from '@babelqueue/core';
20
20
  * });
21
21
  * const consumer = new PulsarConsumer(sub, {
22
22
  * "urn:babel:orders:created": async (env) => { ... },
23
- * });
23
+ * }, { subscriptionType: "Shared" }); // declare it (or pass `client` together with `topic`): see PulsarConsumerOptions
24
24
  * await consumer.run();
25
25
  *
26
26
  * This implements §5 of the broker-bindings contract: the canonical envelope is the message
@@ -28,9 +28,23 @@ import { Envelope, HeaderCarrier, IncomingEnvelope } from '@babelqueue/core';
28
28
  * `bq-trace-id` = trace_id, `bq-message-id` = meta.id, plus `bq-schema-version` /
29
29
  * `bq-source-lang` / `bq-attempts`. The envelope is unchanged (`schema_version` stays 1);
30
30
  * Pulsar is purely additive. A failed handler `negativeAcknowledge`s the message, so it is
31
- * redelivered (at-least-once) and `getRedeliveryCount()` is incremented; the authoritative
32
- * attempt count is the body's `bq-attempts`, reconciled to `max(bq-attempts,
33
- * getRedeliveryCount())` — no −1, because Pulsar's redelivery count is 0-based.
31
+ * redelivered (at-least-once) and `getRedeliveryCount()` is incremented — up to `maxAttempts`
32
+ * deliveries (default 3, ADR-0036): the message that exhausts them is written to `<queue>.dlq`
33
+ * (when a `deadLetterProducer` is given) or acknowledged and dropped. A body that does not decode
34
+ * into an envelope (including an object with no valid identity) is poison: it never reaches a
35
+ * handler, and with dead-lettering on it is recorded in `<queue>.dlq` in the ADR-0035 shape without
36
+ * retry. Per §5.2 / §5.7 the
37
+ * consumer routes on the `bq-job` property (the body's URN is used only when the property is
38
+ * absent or blank) and takes `attempts` from the authoritative `bq-attempts` property (the
39
+ * body's value is used only when the property is absent or not a plain ASCII-decimal integer
40
+ * that fits a 32-bit int), reconciled to `max(bq-attempts, getRedeliveryCount())` — no −1,
41
+ * because Pulsar's redelivery count is 0-based. The handler still receives the body's envelope.
42
+ *
43
+ * **Version gate (§5.7 step 3).** Before the body is decoded the consumer reads the
44
+ * `bq-schema-version` property. A missing or blank value (empty or only ASCII whitespace) changes nothing; any value other than
45
+ * the core's supported `SCHEMA_VERSION` (`"2"`, `"x"`, `"01"`, ...) rejects the message undecoded
46
+ * through the same path as a non-conformant envelope — `onError` (with an error naming the
47
+ * version, and an empty envelope since nothing was decoded) and a `negativeAcknowledge`.
34
48
  *
35
49
  * **Out-of-band headers (ADR-0028).** A `headers` carrier (e.g. a W3C `traceparent` for cross-hop
36
50
  * span linkage) rides as additional native Pulsar **message properties** beside the contract `bq-*`
@@ -70,10 +84,27 @@ interface PulsarReceivedMessage {
70
84
  * satisfies it structurally; a fake satisfies it in tests.
71
85
  */
72
86
  interface PulsarConsumerClient {
87
+ /**
88
+ * The topic the subscription reads. pulsar-client's `Consumer` has **no** such method (only its `Producer`
89
+ * does), so with it the topic comes from the {@link PulsarConsumerOptions.topic} option; a custom
90
+ * subscription wrapper may provide this to make `topic` unnecessary.
91
+ */
92
+ getTopic?(): string;
73
93
  receive(timeoutMs?: number): Promise<PulsarReceivedMessage>;
74
94
  acknowledge(message: PulsarReceivedMessage): Promise<void> | void;
75
95
  negativeAcknowledge(message: PulsarReceivedMessage): Promise<void> | void;
76
96
  }
97
+ /**
98
+ * The subset of the Pulsar client this adapter calls to build its own retry producer. A `Client` from
99
+ * `pulsar-client` satisfies it structurally.
100
+ */
101
+ interface PulsarClientLike {
102
+ createProducer(config: {
103
+ topic: string;
104
+ }): Promise<PulsarProducer>;
105
+ }
106
+ /** The subscription type, as pulsar-client names it (`Key_Shared` is accepted as an alias of `KeyShared`). */
107
+ type PulsarSubscriptionType = "Exclusive" | "Shared" | "Failover" | "KeyShared" | "Key_Shared";
77
108
  /**
78
109
  * Project the envelope's contract fields onto native Pulsar message properties
79
110
  * (string→string): `bq-job` = URN, `bq-trace-id` = trace_id, `bq-message-id` = meta.id, plus
@@ -137,24 +168,125 @@ interface PulsarConsumerOptions {
137
168
  onError?: (error: unknown, envelope: IncomingEnvelope, message: PulsarReceivedMessage) => void;
138
169
  /** Per-receive timeout in ms (default 1000). A timeout yields an empty poll, not an error. */
139
170
  receiveTimeoutMs?: number;
171
+ /**
172
+ * Optional diagnostic hook, called when the `bq-job` property and the body's URN differ (the
173
+ * property wins and the message is routed on it). `envelope` is the body's envelope. Separate
174
+ * from {@link PulsarConsumerOptions.onError}: it is not an error, and anything it throws (or
175
+ * rejects with) is swallowed — it never changes how the message is handled or acknowledged.
176
+ */
177
+ onRoutingMismatch?: (propertyUrn: string, bodyUrn: string, envelope: IncomingEnvelope) => unknown;
178
+ /**
179
+ * The total number of deliveries a message gets, the first included (default 3; `1` = no retry;
180
+ * ADR-0036 decision 1). A failing handler, an unmapped URN without {@link onUnknownUrn} and a poison
181
+ * body with dead-lettering off are retried (`negativeAcknowledge`) while `reconciled attempts + 1`
182
+ * is below it; the delivery that reaches it is dead-lettered (when {@link deadLetterProducer} is
183
+ * set) or acknowledged and dropped. Must be an integer of at least 1.
184
+ */
185
+ maxAttempts?: number;
186
+ /**
187
+ * A producer on the dead-letter topic (by convention `<queue>.dlq`). Dead-lettering is on exactly
188
+ * when it is set; the SDK does not use Pulsar's native `DeadLetterPolicy`. The original message is
189
+ * acknowledged only after the record was sent; a failed send leaves it negatively acknowledged so
190
+ * it is redelivered and the write is tried again.
191
+ */
192
+ deadLetterProducer?: PulsarProducer;
193
+ /**
194
+ * A producer on the consumer's **own** topic. A retry re-publishes the message to that topic with
195
+ * `bq-attempts` (and the body's `attempts`) raised to the counted value and then acknowledges the
196
+ * original — the Go model. The count then lives in the message itself, so the bound holds on every
197
+ * subscription type. Optional when {@link client} is given (the consumer builds the producer itself);
198
+ * a failed re-publish leaves the original negatively acknowledged (never lost).
199
+ *
200
+ * Without a producer or a client a retry is a `negativeAcknowledge`, which advances the native
201
+ * redelivery count only on `Shared` / `Key_Shared`: on `Exclusive` / `Failover` it stays 0 and the retry
202
+ * would never reach `maxAttempts`, so that combination is rejected at construction (see
203
+ * {@link subscriptionType}).
204
+ */
205
+ retryProducer?: PulsarProducer;
206
+ /**
207
+ * The Pulsar client the consumer builds its retry producer from, lazily on the first retry, on
208
+ * {@link topic}. Needs `topic` (pulsar-client's `Consumer` cannot tell its topic). Ignored when
209
+ * {@link retryProducer} is given.
210
+ */
211
+ client?: PulsarClientLike;
212
+ /**
213
+ * The topic the retry producer is created on — the topic the consumer reads. Required together with
214
+ * {@link client} (a pulsar-client `Consumer` has no `getTopic()`); a subscription wrapper that provides
215
+ * `getTopic()` makes it optional.
216
+ */
217
+ topic?: string;
218
+ /**
219
+ * The subscription type the consumer was created with. `Exclusive` and `Failover` cannot bound a
220
+ * nack-driven retry (a negative acknowledgement does not advance the redelivery count there), so with
221
+ * `maxAttempts > 1` they require a {@link retryProducer} or a {@link client}. **Not declaring it counts as
222
+ * `Exclusive`** (pulsar-client's own default, and the fail-closed choice): without a `retryProducer` or a
223
+ * `client` the constructor throws `BabelQueueError`. Declare `"Shared"` or `"Key_Shared"` to keep the
224
+ * `negativeAcknowledge` retry without a producer.
225
+ */
226
+ subscriptionType?: PulsarSubscriptionType;
227
+ /**
228
+ * The queue name written to `dead_letter.original_queue` of a poison record (a decodable envelope
229
+ * uses its own `meta.queue`). Defaults to the {@link deadLetterProducer} topic without its `.dlq`
230
+ * suffix.
231
+ */
232
+ queue?: string;
233
+ /** Receives the "message dropped" and "dead-letter write failed" warnings (default `console.warn`). */
234
+ onWarn?: (message: string) => void;
140
235
  }
236
+ /** Default total number of deliveries (ADR-0036 decision 1). */
237
+ declare const DEFAULT_MAX_ATTEMPTS = 3;
141
238
  /**
142
239
  * Receives from a Pulsar subscription, decodes + validates each message, routes it to the
143
240
  * handler for its URN, and acknowledges it on success. A throwing handler
144
241
  * `negativeAcknowledge`s the message — the broker redelivers it and increments
145
- * `getRedeliveryCount()` (at-least-once); `attempts` is reconciled to
146
- * `max(bq-attempts, getRedeliveryCount())` for the handler.
242
+ * `getRedeliveryCount()` (at-least-once; with a `retryProducer` the message is instead re-published with
243
+ * `bq-attempts` + 1, which also bounds `Exclusive` / `Failover` subscriptions) — until `maxAttempts` deliveries are used up; the last one is
244
+ * dead-lettered to `<queue>.dlq` or acknowledged and dropped (ADR-0036). Routing uses the `bq-job`
245
+ * property (body URN as the fallback); `attempts` is the `bq-attempts` property (body value as the
246
+ * fallback) reconciled to `max(.., getRedeliveryCount())` for the handler.
147
247
  */
148
248
  declare class PulsarConsumer {
149
249
  private readonly consumer;
150
250
  private readonly handlers;
151
251
  private readonly options;
252
+ private readonly maxAttempts;
253
+ private builtRetryProducer;
254
+ private readonly warn;
152
255
  constructor(consumer: PulsarConsumerClient, handlers: BabelHandlers, options?: PulsarConsumerOptions);
256
+ /**
257
+ * Setup check: on `Exclusive` / `Failover` (and an undeclared type) a negative acknowledgement does not advance the native
258
+ * redelivery count, so a retry needs a re-publish. Fail loudly here instead of looping at run time.
259
+ */
260
+ private checkRetryBound;
261
+ private retryTopic;
262
+ /** The retry producer: the one given, else one built (once) from the client; undefined when neither exists. */
263
+ private resolveRetryProducer;
153
264
  /** Receive one message (up to the receive timeout), route + settle it. Returns 1, or 0 on timeout. */
154
265
  poll(): Promise<number>;
155
266
  /** Poll until `signal` aborts. */
156
267
  run(signal?: AbortSignal): Promise<void>;
157
268
  private handle;
269
+ /**
270
+ * The settle decision of a retryable outcome (ADR-0036 decisions 1 and 2). `counted` is the reconciled
271
+ * attempts plus one for this delivery. A poison body with dead-lettering on is recorded without retry;
272
+ * every other outcome retries (`negativeAcknowledge`: the native redelivery count advances, so the
273
+ * next delivery counts one more) while `counted < maxAttempts`, then dead-letters or drops.
274
+ */
275
+ private settle;
276
+ /**
277
+ * Retry one delivery. With a {@link PulsarConsumerOptions.retryProducer}: re-publish to the consumer's
278
+ * own topic carrying `bq-attempts = counted` (reconcile = max(bq-attempts, RedeliveryCount) on the next
279
+ * delivery), then acknowledge the original — only after the send succeeded. Otherwise `negativeAcknowledge`.
280
+ */
281
+ private retry;
282
+ private retryMessage;
283
+ /**
284
+ * Write the DLQ record, then acknowledge the original — only after the send succeeded. A failed send
285
+ * leaves the original negatively acknowledged, so it is redelivered and the write is tried again.
286
+ */
287
+ private deadLetter;
288
+ private deadLetterMessage;
289
+ private notifyRoutingMismatch;
158
290
  }
159
291
 
160
- export { type BabelHandler, type BabelHandlers, type PublishOptions, PulsarConsumer, type PulsarConsumerClient, type PulsarConsumerOptions, type PulsarProducer, type PulsarProducerMessage, PulsarPublisher, type PulsarReceivedMessage, headersOf, pulsarProperties, toPulsarMessage };
292
+ export { type BabelHandler, type BabelHandlers, DEFAULT_MAX_ATTEMPTS, type PublishOptions, type PulsarClientLike, PulsarConsumer, type PulsarConsumerClient, type PulsarConsumerOptions, type PulsarProducer, type PulsarProducerMessage, PulsarPublisher, type PulsarReceivedMessage, type PulsarSubscriptionType, headersOf, pulsarProperties, toPulsarMessage };