Class ConsumerConfig
-
- All Implemented Interfaces:
public final class ConsumerConfigDSL 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.>" }
-
-
Field Summary
Fields Modifier and Type Field Description private final Stringdurableprivate final DeliverPolicydeliverPolicyprivate final AckPolicyackPolicyprivate final DurationackWaitprivate final IntegermaxDeliverprivate final StringfilterSubjectprivate final ReplayPolicyreplayPolicyprivate final IntegersampleFrequencyprivate final LongrateLimitprivate final IntegermaxAckPendingprivate final IntegermaxPullWaitingprivate final IntegermaxBatchprivate final DurationmaxExpiresprivate final DurationinactiveThresholdprivate final Stringdescriptionprivate final StringdeliverGroupprivate final BooleanflowControlprivate final DurationidleHeartbeatprivate final BooleanheadersOnlyprivate final LongstartSequenceprivate final ZonedDateTimestartTimeprivate final StringdeliverSubjectprivate final Integerreplicasprivate final BooleanmemoryStorage
-
Method Summary
Modifier and Type Method Description final StringgetDurable()Durable name for the consumer If null, the consumer will be ephemeral final DeliverPolicygetDeliverPolicy()Deliver policy determines where to start consuming messages final AckPolicygetAckPolicy()Acknowledgment policy for message processing final DurationgetAckWait()How long to wait for acknowledgment before redelivering final IntegergetMaxDeliver()Maximum number of delivery attempts (-1 for unlimited) final StringgetFilterSubject()Filter messages by subject final ReplayPolicygetReplayPolicy()Replay policy for message delivery final IntegergetSampleFrequency()Sample frequency for metrics (0-100, 0 = disabled) final LonggetRateLimit()Rate limit in bits per second (-1 for unlimited) final IntegergetMaxAckPending()Maximum number of outstanding unacknowledged messages final IntegergetMaxPullWaiting()Maximum number of pull requests that may wait on the consumer at once (null = server default) final IntegergetMaxBatch()Largest batch a single pull request may ask this consumer for (null = uncapped) final DurationgetMaxExpires()Maximum expiration duration for pull requests final DurationgetInactiveThreshold()Inactivity threshold before consumer is considered inactive final StringgetDescription()Description of the consumer final StringgetDeliverGroup()Deliver group for queue semantics (push consumers only) final BooleangetFlowControl()Enable flow control for push consumersFlow control prevents the server from overwhelming slow consumers. final DurationgetIdleHeartbeat()Idle heartbeat interval for push consumersThe server will send heartbeat messages if no data messages are sent within this interval. final BooleangetHeadersOnly()Deliver only headers, not payloads final LonggetStartSequence()Start sequence for BY_START_SEQUENCE deliver policy final ZonedDateTimegetStartTime()Start time for BY_START_TIME deliver policy final StringgetDeliverSubject()Deliver subject for push consumers final IntegergetReplicas()Number of replicas for the consumer (-1 for stream default) final BooleangetMemoryStorage()Enable memory storage for the consumer state -
-
Method Detail
-
getDurable
final String getDurable()
Durable name for the consumer If null, the consumer will be ephemeral
-
getDeliverPolicy
final DeliverPolicy getDeliverPolicy()
Deliver policy determines where to start consuming messages
-
getAckPolicy
final AckPolicy getAckPolicy()
Acknowledgment policy for message processing
-
getAckWait
final Duration getAckWait()
How long to wait for acknowledgment before redelivering
-
getMaxDeliver
final Integer getMaxDeliver()
Maximum number of delivery attempts (-1 for unlimited)
-
getFilterSubject
final String getFilterSubject()
Filter messages by subject
-
getReplayPolicy
final ReplayPolicy getReplayPolicy()
Replay policy for message delivery
-
getSampleFrequency
final Integer getSampleFrequency()
Sample frequency for metrics (0-100, 0 = disabled)
-
getRateLimit
final Long getRateLimit()
Rate limit in bits per second (-1 for unlimited)
-
getMaxAckPending
final Integer getMaxAckPending()
Maximum number of outstanding unacknowledged messages
-
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)
-
getMaxExpires
final Duration getMaxExpires()
Maximum expiration duration for pull requests
-
getInactiveThreshold
final Duration getInactiveThreshold()
Inactivity threshold before consumer is considered inactive
-
getDescription
final String getDescription()
Description of the consumer
-
getDeliverGroup
final String getDeliverGroup()
Deliver group for queue semantics (push consumers only)
-
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).
-
getHeadersOnly
final Boolean getHeadersOnly()
Deliver only headers, not payloads
-
getStartSequence
final Long getStartSequence()
Start sequence for BY_START_SEQUENCE deliver policy
-
getStartTime
final ZonedDateTime getStartTime()
Start time for BY_START_TIME deliver policy
-
getDeliverSubject
final String getDeliverSubject()
Deliver subject for push consumers
-
getReplicas
final Integer getReplicas()
Number of replicas for the consumer (-1 for stream default)
-
getMemoryStorage
final Boolean getMemoryStorage()
Enable memory storage for the consumer state
-
-
-
-