@nats-io/jetstream
    Preparing search index...

    Type Alias Batch

    A Batch represents a number of messages staged into a stream atomically. The batch has several limits imposed by the server, such as a batch may not contain more than 1000 messages (including the message starting and ending the batch. And no more than 50 batches on a stream can be active. Batches that are inactive for more than 10 seconds, are abandoned by the server.

    For more information check the JetStream documentation.

    type Batch = {
        count: number;
        id: string;
        add(
            subj: string,
            payload?: Payload,
            opts?: Partial<BatchMessageOptions>,
        ): void;
        add(
            subj: string,
            payload?: Payload,
            opts?: Partial<BatchMessageOptionsWithReply>,
        ): Promise<void>;
        commit(
            subj: string,
            payload?: Payload,
            opts?: Partial<RequestOptions>,
        ): Promise<BatchAck>;
    }
    Index
    count: number

    The current number of messages currently added to the batch

    id: string

    The unique identifier for the batch, generated by the client when the batch is created.

    • Appends the next message to the batch.

      Parameters

      Returns void

    • Appends the next message to the batch, but will wait for the server to acknowledge the message.

      Parameters

      Returns Promise<void>

    • Commits the batch. This will publish the last message on the batch and will remove the batch from the client. If the server rejects the batch (for example, a wrong last sequence or an incomplete batch), it rejects with a JetStreamApiError carrying the server's code and description.

      Parameters

      • subj: string
      • Optionalpayload: Payload
      • Optionalopts: Partial<RequestOptions>

      Returns Promise<BatchAck>