Interface EnvironmentBuilder
- All Known Implementing Classes:
StreamEnvironmentBuilder
Environment
.- See Also:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Helper to configure Nettystatic interface
Helper to configure TLS. -
Method Summary
Modifier and TypeMethodDescriptionaddressResolver
(AddressResolver addressResolver) AnAddressResolver
to potentially change resolved node address to connect to.build()
Create theEnvironment
instance.chunkChecksum
(ChunkChecksum chunkChecksum) The checksum strategy used for chunk checksum.clientProperties
(Map<String, String> clientProperties) Custom client properties to add to default client properties.clientProperty
(String key, String value) Add a custom client properties to default client properties.The AMQP 1.0 codec used to encode and decode AMQP 1.0 messages.compressionCodecFactory
(CompressionCodecFactory compressionCodecFactory) Compression codec factory to use for compression in sub-entry batching.credentialsProvider
(CredentialsProvider credentialsProvider) TheCredentialsProvider
to use.forceReplicaForConsumers
(boolean forceReplica) Flag to force the connection to a stream replica for consumers.The host to connect to.Informational ID for this environment instance.lazyInitialization
(boolean lazy) To delay the connection opening until necessary.maxConsumersByConnection
(int maxConsumersByConnection) The maximum number of consumers allocated to a single connection.maxProducersByConnection
(int maxProducersByConnection) The maximum number of producers allocated to a single connection.maxTrackingConsumersByConnection
(int maxTrackingConsumersByConnection) The maximum number of tracking consumers allocated to a single connection.metricsCollector
(MetricsCollector metricsCollector) Set up aMetricsCollector
.netty()
Helper to configure netty.observationCollector
(ObservationCollector<?> observationCollector) Set up anObservationCollector
.The password to use.port
(int port) The port to use to connect.recoveryBackOffDelayPolicy
(BackOffDelayPolicy recoveryBackOffDelayPolicy) TheBackOffDelayPolicy
to use for connection recovery.requestedHeartbeat
(Duration requestedHeartbeat) The heartbeat to request.requestedMaxFrameSize
(int requestedMaxFrameSize) The maximum frame size to request.rpcTimeout
(Duration timeout) Timeout for RPC calls.saslConfiguration
(SaslConfiguration saslConfiguration) The SASL configuration to use.scheduledExecutorService
(ScheduledExecutorService scheduledExecutorService) Set theScheduledExecutorService
used to: Schedule producers batch sending Handle connection recovery Handle topology updatetls()
Enable and configure TLS.topologyUpdateBackOffDelayPolicy
(BackOffDelayPolicy topologyUpdateBackOffDelayPolicy) TheBackOffDelayPolicy
to use for topology recovery.The URI of a node to connect to.A list of URIs of nodes of the same cluster to use to connect to.The username to use.virtualHost
(String virtualHost) The virtual host to connect to.
-
Method Details
-
uri
The URI of a node to connect to.URI must be of the form
rabbitmq-stream://guest:guest@localhost:5552/%2f
.- Parameters:
uri
-- Returns:
- this builder instance
-
uris
A list of URIs of nodes of the same cluster to use to connect to.URIs must be of the form
rabbitmq-stream://guest:guest@localhost:5552/%2f
.- Parameters:
uris
-- Returns:
- this builder instance
-
addressResolver
AnAddressResolver
to potentially change resolved node address to connect to.Applications can use this abstraction to make sure connection attempts ignore metadata hints and always go to a single point like a load balancer.
The default implementation does not perform any logic, it just returns the passed-in address.
The default implementation is overridden automatically if the following conditions are met: the host to connect to is
localhost
, the user isguest
, and no address resolver has been provided. The client will then always tries to connect tolocalhost
to facilitate local development. Just provide a pass-through address resolver to avoid this behavior, e.g.:Environment.builder() .addressResolver(address -> address) .build();
- Parameters:
addressResolver
-- Returns:
- this builder instance
- See Also:
-
host
The host to connect to.- Parameters:
host
-- Returns:
- this builder instance
-
port
The port to use to connect.- Parameters:
port
-- Returns:
- this builder instance
-
codec
The AMQP 1.0 codec used to encode and decode AMQP 1.0 messages.- Parameters:
codec
-- Returns:
- this builder instance
-
id
Informational ID for this environment instance.This is currently used as a prefix for connection names. The broker does not enforce any kind of uniqueness based on this property. Default to
rabbitmq-stream
.- Parameters:
id
-- Returns:
- this builder instance
-
compressionCodecFactory
Compression codec factory to use for compression in sub-entry batching.- Parameters:
compressionCodecFactory
-- Returns:
- this builder instance
- See Also:
-
rpcTimeout
Timeout for RPC calls.Default is 10 seconds.
- Parameters:
timeout
-- Returns:
- this builder instance
-
saslConfiguration
The SASL configuration to use.- Parameters:
saslConfiguration
-- Returns:
- this builder instance
- See Also:
-
credentialsProvider
TheCredentialsProvider
to use.- Parameters:
credentialsProvider
-- Returns:
- this builder instance
- See Also:
-
username
The username to use.- Parameters:
username
-- Returns:
- this builder instance
-
password
The password to use.- Parameters:
password
-- Returns:
- this builder instance
-
virtualHost
The virtual host to connect to.- Parameters:
virtualHost
-- Returns:
- this builder instance
-
requestedHeartbeat
The heartbeat to request.Default is 60 seconds.
- Parameters:
requestedHeartbeat
-- Returns:
- this builder instance
- See Also:
-
requestedMaxFrameSize
The maximum frame size to request.Default is 1048576.
- Parameters:
requestedMaxFrameSize
-- Returns:
- this builder instance
- See Also:
-
chunkChecksum
The checksum strategy used for chunk checksum.The default is CRC32 based on JDK implementation.
- Parameters:
chunkChecksum
-- Returns:
- this builder instance
-
clientProperties
Custom client properties to add to default client properties.- Parameters:
clientProperties
-- Returns:
- this builder instance
-
clientProperty
Add a custom client properties to default client properties.- Parameters:
key
-value
-- Returns:
- this builder instance
-
metricsCollector
Set up aMetricsCollector
.- Parameters:
metricsCollector
-- Returns:
- this builder instance
-
observationCollector
Set up anObservationCollector
.- Parameters:
observationCollector
-- Returns:
- this builder instance
-
maxProducersByConnection
The maximum number of producers allocated to a single connection.Default is 256, which is the maximum value.
The limit may not be strictly enforced in case of too many concurrent creations.
- Parameters:
maxProducersByConnection
-- Returns:
- this builder instance
-
maxTrackingConsumersByConnection
The maximum number of tracking consumers allocated to a single connection.Default is 50, which is the maximum value.
The limit may not be strictly enforced in case of too many concurrent creations.
- Parameters:
maxTrackingConsumersByConnection
-- Returns:
- this builder instance
-
maxConsumersByConnection
The maximum number of consumers allocated to a single connection.Default is 256, which is the maximum value.
The limit may not be strictly enforced in case of too many concurrent creations.
- Parameters:
maxConsumersByConnection
-- Returns:
- this builder instance
-
scheduledExecutorService
Set theScheduledExecutorService
used to:- Schedule producers batch sending
- Handle connection recovery
- Handle topology update
- Parameters:
scheduledExecutorService
- the service to use- Returns:
- this builder instance
-
recoveryBackOffDelayPolicy
TheBackOffDelayPolicy
to use for connection recovery.The default is a fixed delay of 5 seconds.
- Parameters:
recoveryBackOffDelayPolicy
-- Returns:
- this builder instance
-
topologyUpdateBackOffDelayPolicy
EnvironmentBuilder topologyUpdateBackOffDelayPolicy(BackOffDelayPolicy topologyUpdateBackOffDelayPolicy) TheBackOffDelayPolicy
to use for topology recovery.Topology recovery can kick in when streams leaders and replicas move from nodes to nodes in the cluster.
The default is a first delay of 5 seconds, then 1 second for the next attempts.
- Parameters:
topologyUpdateBackOffDelayPolicy
-- Returns:
- this builder instance
-
lazyInitialization
To delay the connection opening until necessary.No connection will be open before it is necessary (for stream management or producer/consumer creation).
Default is false.
- Parameters:
lazy
-- Returns:
- this builder instance
-
forceReplicaForConsumers
Flag to force the connection to a stream replica for consumers.The library will always prefer to connect to a stream replica to consume from, but it will fall back to the stream leader if no replica is available. This is the default behavior. Set this flag to
true
to make the library wait for a replica to become available if only the stream leader is available. This can lead to longer recovery time but help to offload a stream leader and let it deal only with write requests.Note the library performs only 5 attempts to locate a replica before falling back to the leader when the flag is set to
true
.The
recoveryBackOffDelayPolicy(BackOffDelayPolicy)
andtopologyUpdateBackOffDelayPolicy(BackOffDelayPolicy)
policies control the time between attempts.Do not set this flag to
true
when streams have only 1 member (the leader), e.g. for local development.Default is false.
- Parameters:
forceReplica
- whether to force the connection to a replica or not- Returns:
- this builder instance
- Since:
- 0.13.0
- See Also:
-
build
Environment build()Create theEnvironment
instance.- Returns:
- the configured environment
-
tls
Enable and configure TLS.- Returns:
- the TLS configuration helper
-
netty
Helper to configure netty.- Returns:
- Netty configuration helper
-