Skip to content

API reference

queue(options) creates a Layeron Queue module for durable async delivery, retries, consumers, and dead letters.

Terminal window
import { queue } from "@layeron/modules"

Create a Layeron queue module.

Terminal window
queue(options: QueueModuleOptions): QueueModule

Retry policy for a Layeron queue.

FieldTypeDescription
maxAttemptsint32 | undefinedMaximum delivery attempts before the message moves to dead letters.
backoffQueueBackoffMode | undefinedBackoff algorithm between failed attempts.
initialDelaySecondsint32 | undefinedFirst retry delay in seconds.
maxDelaySecondsint32 | undefinedMaximum retry delay in seconds.

Message retention policy for queue storage.

FieldTypeDescription
daysint32 | undefinedDays to retain queue messages.

Dead letter policy for messages that exhaust retry attempts.

FieldTypeDescription
namestringStable dead letter stream name.
retentionDaysint32 | undefinedDays to retain dead letter records.

Consumer lease and batch policy.

FieldTypeDescription
namestring | undefinedStable consumer name.
batchSizeint32 | undefinedMaximum messages leased per drain call.
concurrencyint32 | undefinedMaximum concurrent handler executions for this consumer.
visibilityTimeoutSecondsint32 | undefinedSeconds before a leased message becomes available again.

Options accepted by queue(options).

FieldTypeDescription
namestringStable queue name inside the Layeron app.
namespacestring | undefinedPlatform namespace for the instance. Defaults to default.
retryQueueRetryOptions | undefinedRetry policy for failed deliveries.
retentionQueueRetentionOptions | undefinedRetention policy for queue messages.
deadLetterQueueDeadLetterOptions | undefinedDead letter policy for exhausted messages.
consumerQueueConsumerOptions | undefinedConsumer lease and batch policy.
observabilityLayeron.Observability.ObservabilityConfig | undefinedObservability settings for queue delivery, retries, drains, and dead letters.

Normalized Layeron queue module.

FieldTypeDescription
name”queue”Module name.
configQueueModuleOptionsNormalized module configuration.
observabilityLayeron.Observability.ObservabilityConfig | undefinedEffective observability policy recorded on the module declaration.

Send options for one message.

FieldTypeDescription
idempotencyKeystring | undefinedApplication idempotency key used to dedupe sends.
delaySecondsint32 | undefinedDelay in seconds before the message becomes visible.
deliverAtstring | undefinedRFC3339 time when the message becomes visible.
headersRecord<unknown> | undefinedSmall structured metadata stored with the message.

Result returned after a message is accepted.

FieldTypeDescription
messageIdstringLayeron message id.
dedupedboolean | undefinedTrue when idempotency reused an existing accepted message.

Retry backoff mode for queue delivery attempts.

ValueDescription
fixedUse the same retry delay for each failed delivery attempt.
exponentialIncrease retry delay after each failed delivery attempt.

Send one message.

Terminal window
queueSend(payload: unknown, options?: QueueSendOptions): QueueSendResult