Hermes MySQL
    Preparing search index...

    Type Alias ConsumerCreationParams<Message>

    type ConsumerCreationParams<Message extends JSONValue> = {
        batchSize?: number;
        consumerName: string;
        getOptions: () => PoolOptions;
        lease?: Duration;
        maxPartitions?: number;
        migrate?: boolean;
        onDbError?: (error: unknown) => void;
        onFailedPublish?: (error: unknown) => void;
        ordering?: "partition" | "none";
        partitionKey?: string;
        pollingConnectionLimit?: number;
        pollInterval?: Duration;
        publish: (message: HermesMessageEnvelope<Message>) => Promise<void> | void;
        retry?: RetryPolicy;
    }

    Type Parameters

    Index
    batchSize?: number

    The maximum number of messages of a partition published per poll.

    100

    consumerName: string

    The name of the consumer. Messages are stored for a consumer and published by the consumers of the same name. At most 250 characters.

    getOptions: () => PoolOptions

    Returns the options of the mysql2 pool that Hermes creates for itself.

    lease?: Duration

    How long a claim of a partition (or of a message) lasts. Another instance takes over the messages of an instance that died after this time.

    Duration.ofSeconds(30)

    maxPartitions?: number

    The maximum number of partitions an instance publishes at the same time (ordering: 'partition').

    10

    migrate?: boolean

    Whether start() runs the migrations of the Hermes tables. Turn it off when you run migrate yourself, e.g. in a deployment pipeline.

    true

    onDbError?: (error: unknown) => void

    Called when a query fails, e.g. when the database is not available.

    onFailedPublish?: (error: unknown) => void

    Called when a message cannot be published.

    ordering?: "partition" | "none"

    How the messages are ordered and shared between many instances of the application.

    • 'partition': the messages of a partition are published one by one, in the order they were stored, by one instance at a time. A message that cannot be published stops its partition until it is published.
    • 'none': the messages are published in any order, many instances share the messages of one partition, and a message that cannot be published does not stop other messages.

    'partition'

    partitionKey?: string

    Publish only the messages of this partition. All the partitions of the consumer when not given: the instances of your application share them.

    pollingConnectionLimit?: number

    The maximum number of connections of the pool that Hermes polls with. It is apart from the pool of OutboxConsumer.getDbConnection, so count both against max_connections of MySQL.

    3

    pollInterval?: Duration

    How long to wait between polls when there was nothing more to publish.

    Duration.ofSeconds(1)

    publish: (message: HermesMessageEnvelope<Message>) => Promise<void> | void

    Publishes a message, e.g. to a message broker. Throw to publish it again later.

    retry?: RetryPolicy

    How long to wait before publishing a failed message again.

    useExponentialRetryPolicy(): 1 second, doubled after every attempt, at most 1 minute