Hermes PostgreSQL
    Preparing search index...

    Type Alias MessageEnvelope<Message>Template

    Simplified message envelope for queueing messages into the outbox.

    This is the type you use when calling outbox.queue() or outbox.send(). Hermes will add additional metadata (position, LSN, redeliveryCount) when delivering the message via the HermesMessageEnvelope.

    Message - The type of the domain message/event

    // Generate deterministic message ID
    const messageId = constructMessageId('PatientRegistered', patientId)

    const envelope: MessageEnvelope<PatientRegisteredEvent> = {
    messageId,
    messageType: 'PatientRegistered',
    message: {
    type: 'PatientRegistered',
    data: { patientId, name, email }
    }
    }

    // Queue with business logic in same transaction
    await sql.begin(async (sql) => {
    await storePatient(patient, sql)
    await outbox.queue(envelope, { tx: sql })
    })

    HermesMessageEnvelope for the full envelope received in publish callback

    type MessageEnvelope<Message extends JSONValue> = {
        message: Message;
        messageId: string;
        messageType: string;
    }

    Type Parameters

    • Message extends JSONValue
    Index

    Properties

    message: Message

    The actual domain message/event data

    messageId: string

    Unique identifier for this message. Must be deterministic for idempotency.

    messageType: string

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