Stratal API Reference
    Preparing search index...

    Class ConsumerRegistry

    Consumer Registry

    Singleton service that holds all registered queue consumers indexed by message type. Consumers declare the message types they handle, and this registry routes messages to the appropriate consumers based on their types.

    Message-Type Routing:

    • Consumers declare messageTypes array (e.g., ['email.send', 'email.batch.send'])
    • When a message arrives, consumers matching the message type are invoked
    • A consumer can handle messages from ANY queue (routing is by type, not queue)
    • Use '*' as a wildcard to handle all message types
    // In consumer.ts
    @Transient()
    export class EmailConsumer implements IQueueConsumer {
    readonly messageTypes = ['email.send', 'email.batch.send']
    // ...
    }

    // In module.ts
    @Module({
    consumers: [EmailConsumer]
    })

    // Application auto-registers via ConsumerRegistry
    this.consumerRegistry.register(consumer)
    Index

    Constructors

    Methods

    • Get all consumers that can handle a specific message type

      Returns consumers that either:

      • Explicitly declare the message type
      • Use '*' wildcard to handle all types

      Parameters

      • messageType: string

        The message type to find consumers for

      Returns IQueueConsumer<unknown>[]

      Array of consumers that can handle this message type

    • Check if any consumers can handle a message type

      Parameters

      • messageType: string

        The message type to check

      Returns boolean

      true if at least one consumer can handle this type