Skip to content

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 ​

ts
new InMemoryQueue(memoryQueueConfiguration?): InMemoryQueue;

Defined in: packages/bus-core/src/transport/in-memory-queue.ts:53

Parameters ​

ParameterType
memoryQueueConfigurationInMemoryQueueConfiguration

Returns ​

InMemoryQueue

Accessors ​

deadLetterQueue ​

Get Signature ​

ts
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 ​

ts
get deadLetterQueueDepth(): number;

Defined in: packages/bus-core/src/transport/in-memory-queue.ts:204

Returns ​

number


depth ​

Get Signature ​

ts
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 ​

ts
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() ​

ts
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 ​

ParameterTypeDescription
messageTransportMessage<InMemoryMessage>The message to be removed from the transport

Returns ​

Promise<void>

Implementation of ​

Transport.deleteMessage


dispose() ​

ts
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 ​

Transport.dispose


fail() ​

ts
fail(transportMessage): Promise<void>;

Defined in: packages/bus-core/src/transport/in-memory-queue.ts:104

Forwards

Parameters ​

ParameterTypeDescription
transportMessageTransportMessage<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 ​

Transport.fail


initialize() ​

ts
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 ​

ParameterTypeDescription
options?TransportInitializationOptionsthe handler registry of the bus

Returns ​

Promise<void>

Implementation of ​

Transport.initialize


prepare() ​

ts
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 ​

ParameterType
coreDependenciesCoreDependencies

Returns ​

void

Implementation of ​

Transport.prepare


publish() ​

ts
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 ​

ParameterTypeDescription
eventTEventA 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 ​

Transport.publish


readNextMessage() ​

ts
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 ​

Transport.readNextMessage


returnMessage() ​

ts
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 ​

ParameterTypeDescription
messageTransportMessage<InMemoryMessage>The message to be returned to the queue for reprocessing

Returns ​

Promise<void>

Implementation of ​

Transport.returnMessage


send() ​

ts
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 ​

ParameterTypeDescription
commandTCommandA 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>

Implementation of ​

Transport.send

Released under the MIT License.