Axinom Mosaic Libraries
    Preparing search index...

    A wrapper around rascal broker to be used by Mosaic services.

    Index

    Methods

    • Attaches a MessageHandler to a subscriptions "On Message" event.

      Type Parameters

      • TContent

      Parameters

      Returns Promise<SubscriberSessionAsPromised>

    • Disconnects and re-initializes the broker.

      Returns Promise<void>

    • Allows to programmatically establish a connection to a vhost.

      Parameters

      • key: string

        vhost name

      Returns Promise<Connection>

    • Returns a boolean indicating if the service is connected to the Broker.

      Returns boolean

    • Total teardown of vhost, subscriptions and queues. Can be used in unit tests in an "After All" function

      Returns Promise<void>

    • Unsubscribes from the 'broker_error' event.

      Parameters

      • event: "broker_error"

        The event name ('broker_error').

      • listener: (data: BrokerErrorEvent) => void

        The callback function to remove.

      Returns void

    • Unsubscribes from the 'broker_reconnected' event.

      Parameters

      • event: "broker_reconnected"

        The event name ('broker_reconnected').

      • listener: (data: BrokerReconnectedEvent) => void

        The callback function to remove.

      Returns void

    • Subscribes to the 'broker_error' event, which is emitted when the broker encounters an error.

      Parameters

      • event: "broker_error"

        The event name ('broker_error').

      • listener: (data: BrokerErrorEvent) => void

        A callback function that receives a BrokerErrorEvent object containing:

        • error: The error that occurred.
        • connection: Details about the connection where the error occurred.

      Returns void

    • Subscribes to the 'broker_reconnected' event, which is emitted when the broker successfully reconnects.

      Parameters

      • event: "broker_reconnected"

        The event name ('broker_reconnected').

      • listener: (data: BrokerReconnectedEvent) => void

        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.

      Returns void

    • Type Parameters

      • T

      Parameters

      • aggregateId: string

        The (database) ID of the aggregate type or use the const UNKNOWN_AGGREGATE_ID or MULTIPLE_AGGREGATE_IDS values.

      • type: { aggregateType: string; messageType: string }

        The aggregate type and message type e.g. channel and ChannelPublishedEvent

      • payload: T

        message payload

      • OptionalenvelopeOverrides: MessageEnvelopeOverrides

        explicitly defined message envelope values, e.g. auth token or message context

      • Optionaloptions: PublicationConfig

        explicitly defined message options, e.g. if additional header values should be passed

      Returns Promise<PublicationSession>

      please use publishCommand or publishEvent instead.

      Publish a message with a defined routing key.

    • Publish a command message with a defined routing key.

      Type Parameters

      • T

      Parameters

      • aggregateId: string

        The (database) ID of the aggregate type or use the const UNKNOWN_AGGREGATE_ID or MULTIPLE_AGGREGATE_IDS values.

      • type: { aggregateType: string; messageType: string }

        The aggregate type and message type e.g. image and EnsureImageExists

      • payload: T

        message payload

      • OptionalenvelopeOverrides: MessageEnvelopeOverrides

        explicitly defined message envelope values, e.g. auth token or message context

      • OptionalcommandConfig: PublicationConfig

        explicitly defined command configuration, e.g. if additional header values should be passed

      Returns Promise<PublicationSession>

    • Publish an event message with a defined routing key.

      Type Parameters

      • T

      Parameters

      • aggregateId: string

        The (database) ID of the aggregate type or use the const UNKNOWN_AGGREGATE_ID or MULTIPLE_AGGREGATE_IDS values.

      • type: { aggregateType: string; messageType: string }

        The aggregate type and message type e.g. channel and ChannelPublishedEvent

      • payload: T

        message payload

      • OptionalenvelopeOverrides: MessageEnvelopeOverrides

        explicitly defined message envelope values, e.g. auth token or message context

      • OptionaleventConfig: PublicationConfig

        explicitly defined event configuration, e.g. if additional header values should be passed

      Returns Promise<PublicationSession>

    • Purges all messages from all queues of all vhosts. Can be used together with unsubscribeAll in unit tests in an "After Each" function

      Returns Promise<void>

    • 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.

      Returns Promise<void>

    • 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.

      Parameters

      • key: string
      • Optionaloverrides: SubscriptionConfig

      Returns Promise<SubscriberSessionAsPromised>

    • Cancels all established subscription sessions. Can be used together with purge in unit tests in an "After Each" function

      Returns Promise<void>

    • Initializes a rascal broker instance using a rascal config and components

      Parameters

      • config: BrokerConfig
      • logger: Logger
      • components: Record<string, unknown> = {}
      • Optionalsigning: Required<
            Pick<
                ValueObject<
                    {
                        rmqChannelMax: () => number;
                        rmqDevMiddleware: () => boolean;
                        rmqEventSigningKeyVersion: () => number;
                        rmqEventSigningKeyVersionsToRevoke: () => number[];
                        rmqEventSigningPrivateKey: () => string;
                        rmqEventSigningPublicKey: () => string;
                        rmqHost: () => string;
                        rmqMgmtHost: () => string | undefined;
                        rmqMgmtPort: () => number | undefined;
                        rmqMgmtProtocol: () => string | undefined;
                        rmqPassword: () => string;
                        rmqPort: () => number;
                        rmqProtocol: () => string;
                        rmqUser: () => string;
                        rmqVHost: () => string;
                        rmqVHostAssert: () => boolean;
                    },
                >,
                "rmqEventSigningPrivateKey"
                | "rmqEventSigningKeyVersion",
            >,
        >

      Returns Promise<Broker>