API reference / @node-ts/bus-core / InMemoryQueue
Class: InMemoryQueue
Defined in: packages/bus-core/src/transport/in-memory-queue.ts:40
An in-memory message queue. This isn't intended for production use as all messages are kept in memory and hence will be wiped when the application or host restarts.
There are however legitimate uses for in-memory queues such as decoupling of non-mission critical code inside of larger applications; so use at your own discretion.
Implements
Constructors
Constructor
new InMemoryQueue(memoryQueueConfiguration?): InMemoryQueue;Defined in: packages/bus-core/src/transport/in-memory-queue.ts:53
Parameters
| Parameter | Type |
|---|---|
memoryQueueConfiguration | InMemoryQueueConfiguration |
Returns
InMemoryQueue
Accessors
deadLetterQueue
Get Signature
get deadLetterQueue(): TransportMessage<InMemoryMessage>[];Defined in: packages/bus-core/src/transport/in-memory-queue.ts:212
Returns all messages sitting in the dead letter queue. This is a copy of the queue so mutative actions on this array will have no consequence.
Returns
TransportMessage<InMemoryMessage>[]
deadLetterQueueDepth
Get Signature
get deadLetterQueueDepth(): number;Defined in: packages/bus-core/src/transport/in-memory-queue.ts:204
Returns
number
depth
Get Signature
get depth(): number;Defined in: packages/bus-core/src/transport/in-memory-queue.ts:200
Gets the queue depth, which is the number of messages both queued and in flight
Returns
number
numberMessagesVisible
Get Signature
get numberMessagesVisible(): number;Defined in: packages/bus-core/src/transport/in-memory-queue.ts:219
Gets the number of messages in the queue, excluding those in flight
Returns
number
Methods
deleteMessage()
deleteMessage(message): Promise<void>;Defined in: packages/bus-core/src/transport/in-memory-queue.ts:154
Removes a message from the underlying transport. This will be called once a message has been successfully handled by any of the message handling functions.
Parameters
| Parameter | Type | Description |
|---|---|---|
message | TransportMessage<InMemoryMessage> | The message to be removed from the transport |
Returns
Promise<void>
Implementation of
dispose()
dispose(): Promise<void>;Defined in: packages/bus-core/src/transport/in-memory-queue.ts:77
Cancels pending retries and reads so that the queue doesn't keep the process alive
Returns
Promise<void>
Implementation of
fail()
fail(transportMessage): Promise<void>;Defined in: packages/bus-core/src/transport/in-memory-queue.ts:104
Forwards
Parameters
| Parameter | Type | Description |
|---|---|---|
transportMessage | TransportMessage<InMemoryMessage> | to the dead letter queue. The message must have been read in from the queue and have a receipt handle. |
Returns
Promise<void>
Implementation of
initialize()
initialize(options?): Promise<void>;Defined in: packages/bus-core/src/transport/in-memory-queue.ts:68
Records which messages have local handlers. Messages without one are discarded when sent.
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | TransportInitializationOptions | the handler registry of the bus |
Returns
Promise<void>
Implementation of
prepare()
prepare(coreDependencies): void;Defined in: packages/bus-core/src/transport/in-memory-queue.ts:57
An optional function that is called before startup that will provide core dependencies to the transport. This can be used to fetch loggers, registries etc that are used in initialization steps
Parameters
| Parameter | Type |
|---|---|
coreDependencies | CoreDependencies |
Returns
void
Implementation of
publish()
publish<TEvent>(event, messageOptions?): Promise<void>;Defined in: packages/bus-core/src/transport/in-memory-queue.ts:90
Publishes an event to the underlying transport. This is generally done to a topic or some other mechanism that consumers can subscribe themselves to
Type Parameters
| Type Parameter |
|---|
TEvent extends Event |
Parameters
| Parameter | Type | Description |
|---|---|---|
event | TEvent | A domain event to be published |
messageOptions? | MessageAttributes<MessageAttributeMap, MessageAttributeMap> | Options that control the behaviour around how the message is sent and additional information that travels with it. |
Returns
Promise<void>
Implementation of
readNextMessage()
readNextMessage(): Promise<
| TransportMessage<InMemoryMessage>
| undefined>;Defined in: packages/bus-core/src/transport/in-memory-queue.ts:114
Returns the next visible message. If none are visible, waits until one becomes visible or receiveTimeoutMs elapses, in which case undefined is returned.
Returns
Promise< | TransportMessage<InMemoryMessage> | undefined>
Implementation of
returnMessage()
returnMessage(message): Promise<void>;Defined in: packages/bus-core/src/transport/in-memory-queue.ts:171
Returns a message to the queue for retry. This will be called if an error was thrown when trying to process a message.
Parameters
| Parameter | Type | Description |
|---|---|---|
message | TransportMessage<InMemoryMessage> | The message to be returned to the queue for reprocessing |
Returns
Promise<void>
Implementation of
send()
send<TCommand>(command, messageOptions?): Promise<void>;Defined in: packages/bus-core/src/transport/in-memory-queue.ts:97
Sends a command to the underlying transport. This is generally done to a topic or some other mechanism that consumers can subscribe themselves to
Type Parameters
| Type Parameter |
|---|
TCommand extends Command |
Parameters
| Parameter | Type | Description |
|---|---|---|
command | TCommand | A domain command to be sent |
messageOptions? | MessageAttributes<MessageAttributeMap, MessageAttributeMap> | Options that control the behaviour around how the message is sent and additional information that travels with it. |
Returns
Promise<void>