Class ConsumerConfig

  • All Implemented Interfaces:

    
    public final class ConsumerConfig
    
                        

    DSL for configuring JetStream consumers

    Example usage:

    val consumerCtx = js.consumer("MY_STREAM", "MY_CONSUMER") {
        durable = "MY_CONSUMER"
        deliverPolicy = DeliverPolicy.ALL
        ackPolicy = AckPolicy.EXPLICIT
        ackWait = 30.seconds
        maxDeliver = 5
        filterSubject = "orders.>"
    }
    • Constructor Detail

    • Method Detail

      • getDurable

         final String getDurable()

        Durable name for the consumer If null, the consumer will be ephemeral

      • getAckWait

         final Duration getAckWait()

        How long to wait for acknowledgment before redelivering

      • getMaxDeliver

         final Integer getMaxDeliver()

        Maximum number of delivery attempts (-1 for unlimited)

      • getRateLimit

         final Long getRateLimit()

        Rate limit in bits per second (-1 for unlimited)

      • getMaxPullWaiting

         final Integer getMaxPullWaiting()

        Maximum number of pull requests that may wait on the consumer at once (null = server default)

      • getMaxBatch

         final Integer getMaxBatch()

        Largest batch a single pull request may ask this consumer for (null = uncapped)

      • getFlowControl

         final Boolean getFlowControl()

        Enable flow control for push consumers

        Flow control prevents the server from overwhelming slow consumers. When enabled, the server sends flow control messages that the NATS client automatically handles. Requires idleHeartbeat to be set.

        Note: Only valid for push consumers (requires deliverSubject).

      • getIdleHeartbeat

         final Duration getIdleHeartbeat()

        Idle heartbeat interval for push consumers

        The server will send heartbeat messages if no data messages are sent within this interval. This allows the consumer to detect connectivity issues.

        When flowControl is enabled, this value determines both the flow control and heartbeat interval. Recommended minimum: 1 second (avoid values like 500ms which cause excessive server load).

      • getStartSequence

         final Long getStartSequence()

        Start sequence for BY_START_SEQUENCE deliver policy

      • getReplicas

         final Integer getReplicas()

        Number of replicas for the consumer (-1 for stream default)