Attaches a MessageHandler to a subscriptions "On Message" event.
The message handler class to handle a specific message type
Optionalmiddleware: OnMessageMiddleware<unknown>[]Apply middleware on receiving a message
Disconnects and re-initializes the broker.
Allows to programmatically establish a connection to a vhost.
vhost name
Returns a boolean indicating if the service is connected to the Broker.
Total teardown of vhost, subscriptions and queues. Can be used in unit tests in an "After All" function
Unsubscribes from the 'broker_error' event.
The event name ('broker_error').
The callback function to remove.
Unsubscribes from the 'broker_reconnected' event.
The event name ('broker_reconnected').
The callback function to remove.
Subscribes to the 'broker_error' event, which is emitted when the broker encounters an error.
The event name ('broker_error').
A callback function that receives a BrokerErrorEvent object containing:
error: The error that occurred.connection: Details about the connection where the error occurred.Subscribes to the 'broker_reconnected' event, which is emitted when the broker successfully reconnects.
The event name ('broker_reconnected').
A callback function that receives a BrokerReconnectedEvent object containing:
connection: Details about the re-established connection.disconnectedDurationInMilliseconds: The duration (in milliseconds) for which the connection was lost.The (database) ID of the aggregate type or use the const UNKNOWN_AGGREGATE_ID or MULTIPLE_AGGREGATE_IDS values.
The aggregate type and message type e.g. channel and ChannelPublishedEvent
message payload
OptionalenvelopeOverrides: MessageEnvelopeOverridesexplicitly defined message envelope values, e.g. auth token or message context
Optionaloptions: PublicationConfigexplicitly defined message options, e.g. if additional header values should be passed
Publish a command message with a defined routing key.
The (database) ID of the aggregate type or use the const UNKNOWN_AGGREGATE_ID or MULTIPLE_AGGREGATE_IDS values.
The aggregate type and message type e.g. image and EnsureImageExists
message payload
OptionalenvelopeOverrides: MessageEnvelopeOverridesexplicitly defined message envelope values, e.g. auth token or message context
OptionalcommandConfig: PublicationConfigexplicitly defined command configuration, e.g. if additional header values should be passed
Publish an event message with a defined routing key.
The (database) ID of the aggregate type or use the const UNKNOWN_AGGREGATE_ID or MULTIPLE_AGGREGATE_IDS values.
The aggregate type and message type e.g. channel and ChannelPublishedEvent
message payload
OptionalenvelopeOverrides: MessageEnvelopeOverridesexplicitly defined message envelope values, e.g. auth token or message context
OptionaleventConfig: PublicationConfigexplicitly defined event configuration, e.g. if additional header values should be passed
Purges all messages from all queues of all vhosts. Can be used together with unsubscribeAll in unit tests in an "After Each" function
Shutdowns the broker, which cancels all subscriptions and waits for a sort amount of time for inflight messages to be acknowledged, before closing channels and disconnecting.
Wrapper for a default rascal subscribe method, allowing explicit subscription to a queue using a dedicated routing key. Consider using addMessageHandler to initialize a subscription and directly attach a message handled to be executed on message received event.
Optionaloverrides: SubscriptionConfigCancels all established subscription sessions. Can be used together with purge in unit tests in an "After Each" function
StaticcreateInitializes a rascal broker instance using a rascal config and components
Optionalcomponents: Record<string, unknown>Optionalsigning: Required<
A wrapper around rascal broker to be used by Mosaic services.