Interface MessageQueueOptions<TMessage>

interface MessageQueueOptions<TMessage extends WithOptionalObjectId> {
    batchDelayMs?: number;
    bestEffort?: boolean;
    bulkWriteOptions?: BulkWriteOptions;
    changeStreamOptions?: ChangeStreamOptions;
    concurrency?: number;
    fastPollMs?: number;
    filter?: Filter<TMessage>;
    group?: string;
    insertOneOptions?: InsertOneOptions;
    maxBatchSize?: number;
    maxRetries?: number;
    maxVisibilitySeconds?: number;
    pollMs?: number;
    visibilityDelaySeconds?: number;
    visibilityTimeoutSeconds?: number;
}

Type Parameters

Hierarchy (View Summary)

Properties

batchDelayMs?: number

Delay before a batch insert.

bestEffort?: boolean

With bestEffort: true (default),

  • batches are inserted with write concern majority,
  • the BatchPublisher will emit error events on write failures,
  • retry inserting messages,
  • and attempt a bulk insert on closure.

With bestEffort: false,

  • batches are inserted with write concern 0,
  • no errors will be emitted on failures,
  • and unwritten messages will be dropped in case of failure or closure.
bulkWriteOptions?: BulkWriteOptions
changeStreamOptions?: ChangeStreamOptions
concurrency?: number

Maximum number of messages to be consumed concurrently for this Consumer. Defaults to 1.

fastPollMs?: number

Maximum follow-up polling delay in milliseconds. Consumers will fast-poll while concurrency is not reached, and after a message is successfully consumed. Defaults to 10 milliseconds.

filter?: Filter<TMessage>

Global MongoDB filter to apply on change stream.

group?: string

Consumer group. Defaults to the collection name.

insertOneOptions?: InsertOneOptions
maxBatchSize?: number

Maximum number of messages per batch to bulk insert.

maxRetries?: number

Maximum number of retries per message. Defaults to 1.

maxVisibilitySeconds?: number

Maximum number of seconds to poll for past messages to consume. Defaults to 3600 seconds (1 hour).

pollMs?: number

Polling interval in milliseconds. Defaults to 1000 milliseconds.

visibilityDelaySeconds?: number

Minimum number of seconds before a published message may be consumed. Defaults to zero.

visibilityTimeoutSeconds?: number

Minimum number of seconds to hide messages from other consumers after receiving. Set at least to 2x of the maximum workload time for message consumption. Defaults to 2 seconds.