Skip to content

API reference / @node-ts/bus-core / Transport

Interface: Transport<TransportMessageType> ​

Defined in: packages/bus-core/src/transport/transport.ts:26

A transport adapter interface that enables the service bus to use a messaging technology.

Type Parameters ​

Type ParameterDefault type
TransportMessageTypeobject

Methods ​

connect()? ​

ts
optional connect(options): Promise<void>;

Defined in: packages/bus-core/src/transport/transport.ts:92

An optional function that will be called on startup. This gives a chance for the transport to establish any connections to the underlying infrastructure.

Parameters ​

ParameterType
optionsTransportConnectionOptions

Returns ​

Promise<void>


deleteMessage() ​

ts
deleteMessage(message): Promise<void>;

Defined in: packages/bus-core/src/transport/transport.ts:71

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<TransportMessageType>The message to be removed from the transport

Returns ​

Promise<void>


disconnect()? ​

ts
optional disconnect(): Promise<void>;

Defined in: packages/bus-core/src/transport/transport.ts:98

An optional function that will be called on shutdown. This gives a chance for the transport to close any connections to the underlying infrastructure.

Returns ​

Promise<void>


dispose()? ​

ts
optional dispose(): Promise<void>;

Defined in: packages/bus-core/src/transport/transport.ts:122

An optional function that will be called when the service bus is shutting down. This is an opportunity for the transport to close out any open requests to fetch messages etc.

Returns ​

Promise<void>


fail() ​

ts
fail(transportMessage): Promise<void>;

Defined in: packages/bus-core/src/transport/transport.ts:55

Forwards

Parameters ​

ParameterTypeDescription
transportMessageTransportMessage<unknown>to the dead letter queue. The message must have been read in from the queue and have a receipt handle.

Returns ​

Promise<void>


initialize()? ​

ts
optional initialize(options): Promise<void>;

Defined in: packages/bus-core/src/transport/transport.ts:116

An optional function that will be called when the service bus is starting. This is an opportunity for the transport to see what messages need to be handled so that subscriptions to the topics can be created.

Parameters ​

ParameterType
optionsTransportInitializationOptions

Returns ​

Promise<void>


prepare() ​

ts
prepare(coreDependencies): void;

Defined in: packages/bus-core/src/transport/transport.ts:86

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


publish() ​

ts
publish<TEvent>(event, messageOptions?): Promise<void>;

Defined in: packages/bus-core/src/transport/transport.ts:34

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>


readNextMessage() ​

ts
readNextMessage(): Promise<
  | TransportMessage<TransportMessageType>
| undefined>;

Defined in: packages/bus-core/src/transport/transport.ts:64

Fetch the next message from the underlying queue. If there are no messages, then undefined should be returned.

Returns ​

Promise< | TransportMessage<TransportMessageType> | undefined>

The message construct from the underlying transport, that includes both the raw message envelope plus the contents or body that contains the @node-ts/bus-messages message.


returnMessage() ​

ts
returnMessage(message): Promise<void>;

Defined in: packages/bus-core/src/transport/transport.ts:78

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<unknown>The message to be returned to the queue for reprocessing

Returns ​

Promise<void>


send() ​

ts
send<TCommand>(command, messageOptions?): Promise<void>;

Defined in: packages/bus-core/src/transport/transport.ts:46

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>


start()? ​

ts
optional start(): Promise<void>;

Defined in: packages/bus-core/src/transport/transport.ts:103

An optional method called on the transport when it should start consuming messages.

Returns ​

Promise<void>


stop()? ​

ts
optional stop(): Promise<void>;

Defined in: packages/bus-core/src/transport/transport.ts:108

An optional method called on the transport when it should no longer consume messages.

Returns ​

Promise<void>

Released under the MIT License.