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 Parameter | Default type |
|---|---|
TransportMessageType | object |
Methods
connect()?
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
| Parameter | Type |
|---|---|
options | TransportConnectionOptions |
Returns
Promise<void>
deleteMessage()
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
| Parameter | Type | Description |
|---|---|---|
message | TransportMessage<TransportMessageType> | The message to be removed from the transport |
Returns
Promise<void>
disconnect()?
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()?
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()
fail(transportMessage): Promise<void>;Defined in: packages/bus-core/src/transport/transport.ts:55
Forwards
Parameters
| Parameter | Type | Description |
|---|---|---|
transportMessage | TransportMessage<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()?
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
| Parameter | Type |
|---|---|
options | TransportInitializationOptions |
Returns
Promise<void>
prepare()
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
| Parameter | Type |
|---|---|
coreDependencies | CoreDependencies |
Returns
void
publish()
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
| 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>
readNextMessage()
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()
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
| Parameter | Type | Description |
|---|---|---|
message | TransportMessage<unknown> | The message to be returned to the queue for reprocessing |
Returns
Promise<void>
send()
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
| 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>
start()?
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()?
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>