Hermes PostgreSQL
    Preparing search index...

    Type Alias HermesMessageEnvelope<Message>Template

    Envelope containing a message along with Hermes-specific metadata.

    This type is passed to your publish callback when Hermes delivers messages from the PostgreSQL replication stream.

    Message - The type of the domain message/event

    const outbox = createOutboxConsumer<DomainEvent>({
    // ...
    publish: async (envelope: HermesMessageEnvelope<DomainEvent>) => {
    console.log(`Delivering message ${envelope.messageId}`)
    console.log(`Attempt #${envelope.redeliveryCount + 1}`)
    console.log(`LSN: ${envelope.lsn}`)

    await messageBroker.publish(envelope.message)
    }
    })

    MessageEnvelope for the simplified envelope used when queueing messages

    type HermesMessageEnvelope<Message extends JSONValue> = {
        lsn: string;
        message: Message;
        messageId: string;
        messageType: string;
        position: number | bigint;
        redeliveryCount: number;
    }

    Type Parameters

    • Message extends JSONValue
    Index

    Properties

    lsn: string

    Log Sequence Number from PostgreSQL WAL (indicates position in replication stream)

    message: Message

    The actual domain message/event data

    messageId: string

    Unique identifier for this message (user-provided, used for idempotency)

    messageType: string

    Type discriminator for the message (e.g., 'PatientRegistered', 'OrderCreated')

    position: number | bigint

    Unique sequential position in the outbox table (auto-incremented)

    redeliveryCount: number

    Number of times delivery has been attempted (0 for first delivery)