Axinom Mosaic Libraries
    Preparing search index...

    Class MessageHandler<TContent>Abstract

    Base class for message handlers to handle incoming messages from the subscribed queue. *

    Type Parameters

    • TContent
    Index

    Constructors

    • The MessageHandler constructor

      Type Parameters

      • TContent

      Parameters

      • messageType: string

        The type of the message which this MessageHandler handles.

      • Optionaloverrides: SubscriptionConfig

        Custom adjustments to overwrite Rascal subscription configuration settings.

      • middleware: OnMessageMiddleware<unknown>[] = []

        Middleware functions that should be executed for this specific message handler in addition to the global ones.

      Returns MessageHandler<TContent>

    Properties

    messageType: string

    The type of the message which this MessageHandler handles.

    middleware: OnMessageMiddleware<unknown>[] = []

    Middleware functions that should be executed for this specific message handler in addition to the global ones.

    overrides?: SubscriptionConfig

    Custom adjustments to overwrite Rascal subscription configuration settings.

    Methods

    • Function to map thrown error of unspecified type to a more human-readable error. Defining this mapping function eliminates the need to wrap onMessage contents into an explicit try-catch block.

      Parameters

      • error: unknown

      Returns Error

    • Main message handling function.

      Parameters

      • payload: TContent

        non-binary message payload (usually a json)

      • message: MessageInfo<TContent>

        message with all related message metadata, including message envelope

      • ackOrNack: AckOrNack

        acknowledgment or rejection callback that can be called to forcefully complete the message processing.

      Returns Promise<void>

    • Function that will be called after the last retry attempt has failed. Useful for handling errors in an explicit way.

      Parameters

      • payload: TContent

        non-binary message payload (usually a json)

      • message: MessageInfo<TContent>

        message with all related message metadata, including message envelope

      • error: Error

        error object that caused message processing to repeatedly fail

      Returns Promise<void>