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

Hierarchy

  • BrokerProxy

Constructors

Properties

attachBrokerHandlers: any
broker: any
eventSigning?: any
getPublication: any
getSubscription: any
isConnectedToBroker: any
logger: any
onBrokerBlocked: any
onBrokerBusy: any
onBrokerError: any
onBrokerReady: any
onBrokerUnblocked: any
onBrokerVhostInitialized: any
publications: any
subscriptions: any
instance: any

Methods

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

    Type Parameters

    • TContent

    Parameters

    • handler: MessageHandler<TContent>

      The message handler class to handle a specific message type

    • Optional middleware: OnMessageMiddleware<unknown>[]

      Apply middleware on receiving a message

    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>

  • 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

      • aggregateType: string
      • messageType: string
    • payload: T

      message payload

    • Optional envelopeOverrides: MessageEnvelopeOverrides

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

    • Optional options: PublicationConfig

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

    Returns Promise<PublicationSession>

    Deprecated

    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

      • aggregateType: string
      • messageType: string
    • payload: T

      message payload

    • Optional envelopeOverrides: MessageEnvelopeOverrides

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

    • Optional commandConfig: 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

      • aggregateType: string
      • messageType: string
    • payload: T

      message payload

    • Optional envelopeOverrides: MessageEnvelopeOverrides

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

    • Optional eventConfig: 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
    • Optional overrides: 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
    • Optional components: Record<string, unknown>
    • Optional signing: Required<Pick<ValueObject<{
          rmqChannelMax: (() => number);
          rmqDevMiddleware: (() => boolean);
          rmqEventSigningKeyVersion: (() => number);
          rmqEventSigningKeyVersionsToRevoke: (() => number[]);
          rmqEventSigningPrivateKey: (() => string);
          rmqEventSigningPublicKey: (() => string);
          rmqHost: (() => string);
          rmqMgmtHost: (() => undefined | string);
          rmqMgmtPort: (() => undefined | number);
          rmqMgmtProtocol: (() => undefined | string);
          rmqPassword: (() => string);
          rmqPort: (() => number);
          rmqProtocol: (() => string);
          rmqUser: (() => string);
          rmqVHost: (() => string);
          rmqVHostAssert: (() => boolean);
      }>, "rmqEventSigningPrivateKey" | "rmqEventSigningKeyVersion">>

    Returns Promise<BrokerProxy>

Generated using TypeDoc