Class ConsumerConfigBuilder
-
- All Implemented Interfaces:
public final class ConsumerConfigBuilderBuilder for JetStream consumer configuration
-
-
Field Summary
Fields Modifier and Type Field Description private Stringdurableprivate Stringnameprivate DeliverPolicydeliverPolicyprivate AckPolicyackPolicyprivate DurationackWaitprivate IntegermaxDeliverprivate StringfilterSubjectprivate List<String>filterSubjectsprivate ReplayPolicyreplayPolicyprivate IntegersampleFrequencyprivate LongrateLimitprivate IntegermaxAckPendingprivate IntegermaxPullWaitingprivate IntegermaxBatchprivate DurationmaxExpiresprivate DurationinactiveThresholdprivate Stringdescriptionprivate StringdeliverGroupprivate BooleanflowControlprivate DurationidleHeartbeatprivate BooleanheadersOnlyprivate LongstartSequenceprivate ZonedDateTimestartTimeprivate StringdeliverSubjectprivate Integerreplicasprivate BooleanmemoryStorageprivate List<Duration>backoffprivate Map<String, String>metadata
-
Constructor Summary
Constructors Constructor Description ConsumerConfigBuilder()
-
Method Summary
Modifier and Type Method Description final StringgetDurable()Durable name for the consumer If null, the consumer will be ephemeral final UnitsetDurable(String <set-?>)Durable name for the consumer If null, the consumer will be ephemeral final StringgetName()Name for the consumer, without making it durableA named consumer is still ephemeral - the server reaps it once inactiveThreshold passes - but it is addressable and re-attachable in the meantime, where an unnamed one gets a server-generated name nobody can predict. final UnitsetName(String <set-?>)Name for the consumer, without making it durableA named consumer is still ephemeral - the server reaps it once inactiveThreshold passes - but it is addressable and re-attachable in the meantime, where an unnamed one gets a server-generated name nobody can predict. final DeliverPolicygetDeliverPolicy()Deliver policy determines where to start consuming messages final UnitsetDeliverPolicy(DeliverPolicy <set-?>)Deliver policy determines where to start consuming messages final AckPolicygetAckPolicy()Acknowledgment policy for message processing final UnitsetAckPolicy(AckPolicy <set-?>)Acknowledgment policy for message processing final DurationgetAckWait()How long to wait for acknowledgment before redelivering final UnitsetAckWait(Duration <set-?>)How long to wait for acknowledgment before redelivering final IntegergetMaxDeliver()Maximum number of delivery attempts (-1 for unlimited) final UnitsetMaxDeliver(Integer <set-?>)Maximum number of delivery attempts (-1 for unlimited) final StringgetFilterSubject()Filter messages by subjectOne subject; use filterSubjects for several. final UnitsetFilterSubject(String <set-?>)Filter messages by subjectOne subject; use filterSubjects for several. final List<String>getFilterSubjects()Filter messages by several subjectsThe plural form of filterSubject; a consumer over orders.createdandorders.cancelledwithout theorders.updatedin between.final UnitsetFilterSubjects(List<String> <set-?>)Filter messages by several subjectsThe plural form of filterSubject; a consumer over orders.createdandorders.cancelledwithout theorders.updatedin between.final ReplayPolicygetReplayPolicy()Replay policy for message delivery final UnitsetReplayPolicy(ReplayPolicy <set-?>)Replay policy for message delivery final IntegergetSampleFrequency()Sample frequency for metrics (0-100, 0 = disabled) final UnitsetSampleFrequency(Integer <set-?>)Sample frequency for metrics (0-100, 0 = disabled) final LonggetRateLimit()Rate limit in bits per second (-1 for unlimited) final UnitsetRateLimit(Long <set-?>)Rate limit in bits per second (-1 for unlimited) final IntegergetMaxAckPending()Maximum number of outstanding unacknowledged messages final UnitsetMaxAckPending(Integer <set-?>)Maximum number of outstanding unacknowledged messages final IntegergetMaxPullWaiting()Maximum number of pull requests that may wait on the consumer at once null- the default - leaves the limit to the server, which allows 512.final UnitsetMaxPullWaiting(Integer <set-?>)Maximum number of pull requests that may wait on the consumer at once null- the default - leaves the limit to the server, which allows 512.final IntegergetMaxBatch()Largest batch a single pull request may ask this consumer for null- the default - leaves the limit to the server, which does not cap batches.final UnitsetMaxBatch(Integer <set-?>)Largest batch a single pull request may ask this consumer for null- the default - leaves the limit to the server, which does not cap batches.final DurationgetMaxExpires()Longest a pull request against this consumer may wait ZERO- the default - leaves the limit to the server.final UnitsetMaxExpires(Duration <set-?>)Longest a pull request against this consumer may wait ZERO- the default - leaves the limit to the server.final DurationgetInactiveThreshold()Inactivity threshold before consumer is considered inactive final UnitsetInactiveThreshold(Duration <set-?>)Inactivity threshold before consumer is considered inactive final StringgetDescription()Description of the consumer final UnitsetDescription(String <set-?>)Description of the consumer final StringgetDeliverGroup()Deliver group for queue semantics (push consumers only)A deliver group balances among subscribers of one consumer's deliver subject, so it needs a consumer every collector can share - however the group was asked for. final UnitsetDeliverGroup(String <set-?>)Deliver group for queue semantics (push consumers only)A deliver group balances among subscribers of one consumer's deliver subject, so it needs a consumer every collector can share - however the group was asked for. final BooleangetFlowControl()Enable flow control for push consumersFlow control prevents the server from overwhelming slow consumers. final UnitsetFlowControl(Boolean <set-?>)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 UnitsetIdleHeartbeat(Duration <set-?>)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 UnitsetHeadersOnly(Boolean <set-?>)Deliver only headers, not payloads final LonggetStartSequence()Start sequence for BY_START_SEQUENCE deliver policy final UnitsetStartSequence(Long <set-?>)Start sequence for BY_START_SEQUENCE deliver policy final ZonedDateTimegetStartTime()Start time for BY_START_TIME deliver policy final UnitsetStartTime(ZonedDateTime <set-?>)Start time for BY_START_TIME deliver policy final StringgetDeliverSubject()Deliver subject for push consumers final UnitsetDeliverSubject(String <set-?>)Deliver subject for push consumers final IntegergetReplicas()Number of replicas for the consumer (-1 for stream default) final UnitsetReplicas(Integer <set-?>)Number of replicas for the consumer (-1 for stream default) final BooleangetMemoryStorage()Enable memory storage for the consumer state final UnitsetMemoryStorage(Boolean <set-?>)Enable memory storage for the consumer state final List<Duration>getBackoff()How long to wait before each redelivery, instead of a fixed ackWaitThe standard poison-message mitigation: listOf(1.seconds, 5.seconds, 30.seconds)retries quickly for a blip and slowly for an outage, and with maxDeliver set it bounds how long a message can keep failing before it is dead-lettered.final UnitsetBackoff(List<Duration> <set-?>)How long to wait before each redelivery, instead of a fixed ackWaitThe standard poison-message mitigation: listOf(1.seconds, 5.seconds, 30.seconds)retries quickly for a blip and slowly for an outage, and with maxDeliver set it bounds how long a message can keep failing before it is dead-lettered.final Map<String, String>getMetadata()Free-form key-value pairs stored on the consumerFor whoever has to work out later which deployment created it. final UnitsetMetadata(Map<String, String> <set-?>)Free-form key-value pairs stored on the consumerFor whoever has to work out later which deployment created it. final Unitraw(Function1<ConsumerConfiguration.Builder, Unit> customize)Reach a jnats consumer setting this DSL does not model ConsumerConfiguration.Buildercarries more than natsy has an opinion about;maxBytes,priorityGroups,priorityPolicyandpauseUntilare all reachable here rather than being unreachable until natsy grows a property for each.-
-
Method Detail
-
getDurable
final String getDurable()
Durable name for the consumer If null, the consumer will be ephemeral
-
setDurable
final Unit setDurable(String <set-?>)
Durable name for the consumer If null, the consumer will be ephemeral
-
getName
final String getName()
Name for the consumer, without making it durable
A named consumer is still ephemeral - the server reaps it once inactiveThreshold passes - but it is addressable and re-attachable in the meantime, where an unnamed one gets a server-generated name nobody can predict. Set durable instead for a consumer that outlives its subscribers.
-
setName
final Unit setName(String <set-?>)
Name for the consumer, without making it durable
A named consumer is still ephemeral - the server reaps it once inactiveThreshold passes - but it is addressable and re-attachable in the meantime, where an unnamed one gets a server-generated name nobody can predict. Set durable instead for a consumer that outlives its subscribers.
-
getDeliverPolicy
final DeliverPolicy getDeliverPolicy()
Deliver policy determines where to start consuming messages
-
setDeliverPolicy
final Unit setDeliverPolicy(DeliverPolicy <set-?>)
Deliver policy determines where to start consuming messages
-
getAckPolicy
final AckPolicy getAckPolicy()
Acknowledgment policy for message processing
-
setAckPolicy
final Unit setAckPolicy(AckPolicy <set-?>)
Acknowledgment policy for message processing
-
getAckWait
final Duration getAckWait()
How long to wait for acknowledgment before redelivering
-
setAckWait
final Unit setAckWait(Duration <set-?>)
How long to wait for acknowledgment before redelivering
-
getMaxDeliver
final Integer getMaxDeliver()
Maximum number of delivery attempts (-1 for unlimited)
-
setMaxDeliver
final Unit setMaxDeliver(Integer <set-?>)
Maximum number of delivery attempts (-1 for unlimited)
-
getFilterSubject
final String getFilterSubject()
Filter messages by subject
One subject; use filterSubjects for several. They are two names for one server field, so setting both is rejected rather than resolved by precedence.
-
setFilterSubject
final Unit setFilterSubject(String <set-?>)
Filter messages by subject
One subject; use filterSubjects for several. They are two names for one server field, so setting both is rejected rather than resolved by precedence.
-
getFilterSubjects
final List<String> getFilterSubjects()
Filter messages by several subjects
The plural form of filterSubject; a consumer over
orders.createdandorders.cancelledwithout theorders.updatedin between.
-
setFilterSubjects
final Unit setFilterSubjects(List<String> <set-?>)
Filter messages by several subjects
The plural form of filterSubject; a consumer over
orders.createdandorders.cancelledwithout theorders.updatedin between.
-
getReplayPolicy
final ReplayPolicy getReplayPolicy()
Replay policy for message delivery
-
setReplayPolicy
final Unit setReplayPolicy(ReplayPolicy <set-?>)
Replay policy for message delivery
-
getSampleFrequency
final Integer getSampleFrequency()
Sample frequency for metrics (0-100, 0 = disabled)
-
setSampleFrequency
final Unit setSampleFrequency(Integer <set-?>)
Sample frequency for metrics (0-100, 0 = disabled)
-
getRateLimit
final Long getRateLimit()
Rate limit in bits per second (-1 for unlimited)
-
setRateLimit
final Unit setRateLimit(Long <set-?>)
Rate limit in bits per second (-1 for unlimited)
-
getMaxAckPending
final Integer getMaxAckPending()
Maximum number of outstanding unacknowledged messages
-
setMaxAckPending
final Unit setMaxAckPending(Integer <set-?>)
Maximum number of outstanding unacknowledged messages
-
getMaxPullWaiting
final Integer getMaxPullWaiting()
Maximum number of pull requests that may wait on the consumer at once
null- the default - leaves the limit to the server, which allows 512.
-
setMaxPullWaiting
final Unit setMaxPullWaiting(Integer <set-?>)
Maximum number of pull requests that may wait on the consumer at once
null- the default - leaves the limit to the server, which allows 512.
-
getMaxBatch
final Integer getMaxBatch()
Largest batch a single pull request may ask this consumer for
null- the default - leaves the limit to the server, which does not cap batches. Set it only to cap them deliberately: the server answers any larger fetch with a 409 that the client treats as a handled status, so an over-sized fetch quietly returns nothing.
-
setMaxBatch
final Unit setMaxBatch(Integer <set-?>)
Largest batch a single pull request may ask this consumer for
null- the default - leaves the limit to the server, which does not cap batches. Set it only to cap them deliberately: the server answers any larger fetch with a 409 that the client treats as a handled status, so an over-sized fetch quietly returns nothing.
-
getMaxExpires
final Duration getMaxExpires()
Longest a pull request against this consumer may wait
ZERO- the default - leaves the limit to the server. Set it only to cap expiry deliberately: the server answers any longer fetch with a 409 that the client treats as a handled status, so an over-long fetch quietly returns nothing rather than fail.
-
setMaxExpires
final Unit setMaxExpires(Duration <set-?>)
Longest a pull request against this consumer may wait
ZERO- the default - leaves the limit to the server. Set it only to cap expiry deliberately: the server answers any longer fetch with a 409 that the client treats as a handled status, so an over-long fetch quietly returns nothing rather than fail.
-
getInactiveThreshold
final Duration getInactiveThreshold()
Inactivity threshold before consumer is considered inactive
-
setInactiveThreshold
final Unit setInactiveThreshold(Duration <set-?>)
Inactivity threshold before consumer is considered inactive
-
getDescription
final String getDescription()
Description of the consumer
-
setDescription
final Unit setDescription(String <set-?>)
Description of the consumer
-
getDeliverGroup
final String getDeliverGroup()
Deliver group for queue semantics (push consumers only)
A deliver group balances among subscribers of one consumer's deliver subject, so it needs a consumer every collector can share - however the group was asked for. Pass
consumerNameto JetStreamContext.subscribe, or set durable here. Without one, every collector creates its own ephemeral consumer on its own inbox and receives every message instead of a share of the work.This is the same field JetStreamContext.subscribe's
queueparameter writes. That spelling is refused at the call whenconsumerNameis missing; this one is refused at collection, once the configuration has been built and both spellings are visible.
-
setDeliverGroup
final Unit setDeliverGroup(String <set-?>)
Deliver group for queue semantics (push consumers only)
A deliver group balances among subscribers of one consumer's deliver subject, so it needs a consumer every collector can share - however the group was asked for. Pass
consumerNameto JetStreamContext.subscribe, or set durable here. Without one, every collector creates its own ephemeral consumer on its own inbox and receives every message instead of a share of the work.This is the same field JetStreamContext.subscribe's
queueparameter writes. That spelling is refused at the call whenconsumerNameis missing; this one is refused at collection, once the configuration has been built and both spellings are visible.
-
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).
-
setFlowControl
final Unit setFlowControl(Boolean <set-?>)
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).
-
setIdleHeartbeat
final Unit setIdleHeartbeat(Duration <set-?>)
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
-
setHeadersOnly
final Unit setHeadersOnly(Boolean <set-?>)
Deliver only headers, not payloads
-
getStartSequence
final Long getStartSequence()
Start sequence for BY_START_SEQUENCE deliver policy
-
setStartSequence
final Unit setStartSequence(Long <set-?>)
Start sequence for BY_START_SEQUENCE deliver policy
-
getStartTime
final ZonedDateTime getStartTime()
Start time for BY_START_TIME deliver policy
-
setStartTime
final Unit setStartTime(ZonedDateTime <set-?>)
Start time for BY_START_TIME deliver policy
-
getDeliverSubject
final String getDeliverSubject()
Deliver subject for push consumers
-
setDeliverSubject
final Unit setDeliverSubject(String <set-?>)
Deliver subject for push consumers
-
getReplicas
final Integer getReplicas()
Number of replicas for the consumer (-1 for stream default)
-
setReplicas
final Unit setReplicas(Integer <set-?>)
Number of replicas for the consumer (-1 for stream default)
-
getMemoryStorage
final Boolean getMemoryStorage()
Enable memory storage for the consumer state
-
setMemoryStorage
final Unit setMemoryStorage(Boolean <set-?>)
Enable memory storage for the consumer state
-
getBackoff
final List<Duration> getBackoff()
How long to wait before each redelivery, instead of a fixed ackWait
The standard poison-message mitigation:
listOf(1.seconds, 5.seconds, 30.seconds)retries quickly for a blip and slowly for an outage, and with maxDeliver set it bounds how long a message can keep failing before it is dead-lettered. The list overrides ackWait for as many redeliveries as it has entries, and the last entry applies to every attempt after that (jnatsio/nats/client/api/ConsumerConfiguration.java:1407).
-
setBackoff
final Unit setBackoff(List<Duration> <set-?>)
How long to wait before each redelivery, instead of a fixed ackWait
The standard poison-message mitigation:
listOf(1.seconds, 5.seconds, 30.seconds)retries quickly for a blip and slowly for an outage, and with maxDeliver set it bounds how long a message can keep failing before it is dead-lettered. The list overrides ackWait for as many redeliveries as it has entries, and the last entry applies to every attempt after that (jnatsio/nats/client/api/ConsumerConfiguration.java:1407).
-
getMetadata
final Map<String, String> getMetadata()
Free-form key-value pairs stored on the consumer
For whoever has to work out later which deployment created it. The server keeps its own
_nats.*entries alongside these and they are left alone.
-
setMetadata
final Unit setMetadata(Map<String, String> <set-?>)
Free-form key-value pairs stored on the consumer
For whoever has to work out later which deployment created it. The server keeps its own
_nats.*entries alongside these and they are left alone.
-
raw
final Unit raw(Function1<ConsumerConfiguration.Builder, Unit> customize)
Reach a jnats consumer setting this DSL does not model
ConsumerConfiguration.Buildercarries more than natsy has an opinion about;maxBytes,priorityGroups,priorityPolicyandpauseUntilare all reachable here rather than being unreachable until natsy grows a property for each.Applied last, after everything else this block sets, so it can also override those. Blocks accumulate, and they apply wherever natsy patches a consumer it found already there: a
raw { }in aconsumer { }block, or in ConsumerContext.update, is part of the patch, exactly like an assigned property.Binding is not one of those paths.
subscribe(consumerName = …)naming a consumer that already exists hands jnats the server's copy and builds nothing, so a block here could only be discarded - and is refused instead, by name, like any other configuration that binding would ignore.raw { maxBytes(1024 * 1024) }
-
-
-
-