public class StreamEnvironmentBuilder extends Object implements EnvironmentBuilder
EnvironmentBuilder.NettyConfiguration, EnvironmentBuilder.TlsConfiguration| Constructor and Description |
|---|
StreamEnvironmentBuilder() |
| Modifier and Type | Method and Description |
|---|---|
EnvironmentBuilder |
addressResolver(AddressResolver addressResolver)
An
AddressResolver to potentially change resolved node address to connect to. |
Environment |
build()
Create the
Environment instance. |
StreamEnvironmentBuilder |
chunkChecksum(ChunkChecksum chunkChecksum)
The checksum strategy used for chunk checksum.
|
StreamEnvironmentBuilder |
clientProperties(Map<String,String> clientProperties)
Custom client properties to add to default client properties.
|
StreamEnvironmentBuilder |
clientProperty(String key,
String value)
Add a custom client properties to default client properties.
|
StreamEnvironmentBuilder |
codec(Codec codec)
The AMQP 1.0 codec used to encode and decode AMQP 1.0 messages.
|
EnvironmentBuilder |
compressionCodecFactory(CompressionCodecFactory compressionCodecFactory)
Compression codec factory to use for compression in sub-entry batching.
|
StreamEnvironmentBuilder |
credentialsProvider(CredentialsProvider credentialsProvider)
The
CredentialsProvider to use. |
EnvironmentBuilder |
forceReplicaForConsumers(boolean forceReplica)
Flag to force the connection to a stream replica for consumers.
|
StreamEnvironmentBuilder |
host(String host)
The host to connect to.
|
EnvironmentBuilder |
id(String id)
Informational ID for this environment instance.
|
EnvironmentBuilder |
lazyInitialization(boolean lazy)
To delay the connection opening until necessary.
|
EnvironmentBuilder |
maxConsumersByConnection(int maxConsumersByConnection)
The maximum number of consumers allocated to a single connection.
|
EnvironmentBuilder |
maxProducersByConnection(int maxProducersByConnection)
The maximum number of producers allocated to a single connection.
|
EnvironmentBuilder |
maxTrackingConsumersByConnection(int maxTrackingConsumersByConnection)
The maximum number of tracking consumers allocated to a single connection.
|
StreamEnvironmentBuilder |
metricsCollector(MetricsCollector metricsCollector)
Set up a
MetricsCollector. |
EnvironmentBuilder.NettyConfiguration |
netty()
Helper to configure netty.
|
EnvironmentBuilder |
observationCollector(ObservationCollector<?> observationCollector)
Set up an
ObservationCollector. |
StreamEnvironmentBuilder |
password(String password)
The password to use.
|
StreamEnvironmentBuilder |
port(int port)
The port to use to connect.
|
EnvironmentBuilder |
recoveryBackOffDelayPolicy(BackOffDelayPolicy recoveryBackOffDelayPolicy)
The
BackOffDelayPolicy to use for connection recovery. |
StreamEnvironmentBuilder |
requestedHeartbeat(Duration requestedHeartbeat)
The heartbeat to request.
|
StreamEnvironmentBuilder |
requestedMaxFrameSize(int requestedMaxFrameSize)
The maximum frame size to request.
|
EnvironmentBuilder |
rpcTimeout(Duration timeout)
Timeout for RPC calls.
|
StreamEnvironmentBuilder |
saslConfiguration(SaslConfiguration saslConfiguration)
The SASL configuration to use.
|
EnvironmentBuilder |
scheduledExecutorService(ScheduledExecutorService scheduledExecutorService)
Set the
ScheduledExecutorService used to:
Schedule producers batch sending
Handle connection recovery
Handle topology update
|
EnvironmentBuilder.TlsConfiguration |
tls()
Enable and configure TLS.
|
EnvironmentBuilder |
topologyUpdateBackOffDelayPolicy(BackOffDelayPolicy topologyUpdateBackOffDelayPolicy)
The
BackOffDelayPolicy to use for topology recovery. |
StreamEnvironmentBuilder |
uri(String uriString)
The URI of a node to connect to.
|
StreamEnvironmentBuilder |
uris(List<String> uris)
A list of URIs of nodes of the same cluster to use to connect to.
|
StreamEnvironmentBuilder |
username(String username)
The username to use.
|
StreamEnvironmentBuilder |
virtualHost(String virtualHost)
The virtual host to connect to.
|
public StreamEnvironmentBuilder uri(String uriString)
EnvironmentBuilderURI must be of the form rabbitmq-stream://guest:guest@localhost:5552/%2f.
uri in interface EnvironmentBuilderpublic StreamEnvironmentBuilder uris(List<String> uris)
EnvironmentBuilderURIs must be of the form rabbitmq-stream://guest:guest@localhost:5552/%2f.
uris in interface EnvironmentBuilderpublic StreamEnvironmentBuilder host(String host)
EnvironmentBuilderhost in interface EnvironmentBuilderpublic StreamEnvironmentBuilder port(int port)
EnvironmentBuilderport in interface EnvironmentBuilderpublic StreamEnvironmentBuilder codec(Codec codec)
EnvironmentBuildercodec in interface EnvironmentBuilderpublic EnvironmentBuilder compressionCodecFactory(CompressionCodecFactory compressionCodecFactory)
EnvironmentBuildercompressionCodecFactory in interface EnvironmentBuilderProducerBuilder.subEntrySize(int),
ProducerBuilder.compression(Compression)public EnvironmentBuilder id(String id)
EnvironmentBuilderThis 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.
id in interface EnvironmentBuilderpublic EnvironmentBuilder rpcTimeout(Duration timeout)
EnvironmentBuilderDefault is 10 seconds.
rpcTimeout in interface EnvironmentBuilderpublic StreamEnvironmentBuilder saslConfiguration(SaslConfiguration saslConfiguration)
EnvironmentBuildersaslConfiguration in interface EnvironmentBuilderEnvironmentBuilder.credentialsProvider(CredentialsProvider)public StreamEnvironmentBuilder credentialsProvider(CredentialsProvider credentialsProvider)
EnvironmentBuilderCredentialsProvider to use.credentialsProvider in interface EnvironmentBuilderEnvironmentBuilder.saslConfiguration(SaslConfiguration)public StreamEnvironmentBuilder username(String username)
EnvironmentBuilderusername in interface EnvironmentBuilderpublic StreamEnvironmentBuilder password(String password)
EnvironmentBuilderpassword in interface EnvironmentBuilderpublic StreamEnvironmentBuilder virtualHost(String virtualHost)
EnvironmentBuildervirtualHost in interface EnvironmentBuilderpublic StreamEnvironmentBuilder requestedHeartbeat(Duration requestedHeartbeat)
EnvironmentBuilderDefault is 60 seconds.
requestedHeartbeat in interface EnvironmentBuilderpublic StreamEnvironmentBuilder requestedMaxFrameSize(int requestedMaxFrameSize)
EnvironmentBuilderDefault is 1048576.
requestedMaxFrameSize in interface EnvironmentBuilderpublic StreamEnvironmentBuilder chunkChecksum(ChunkChecksum chunkChecksum)
EnvironmentBuilderThe default is CRC32 based on JDK implementation.
chunkChecksum in interface EnvironmentBuilderpublic StreamEnvironmentBuilder clientProperties(Map<String,String> clientProperties)
EnvironmentBuilderclientProperties in interface EnvironmentBuilderpublic StreamEnvironmentBuilder clientProperty(String key, String value)
EnvironmentBuilderclientProperty in interface EnvironmentBuilderpublic StreamEnvironmentBuilder metricsCollector(MetricsCollector metricsCollector)
EnvironmentBuilderMetricsCollector.metricsCollector in interface EnvironmentBuilderpublic EnvironmentBuilder scheduledExecutorService(ScheduledExecutorService scheduledExecutorService)
EnvironmentBuilderScheduledExecutorService used to:
scheduledExecutorService in interface EnvironmentBuilderscheduledExecutorService - the service to usepublic EnvironmentBuilder recoveryBackOffDelayPolicy(BackOffDelayPolicy recoveryBackOffDelayPolicy)
EnvironmentBuilderBackOffDelayPolicy to use for connection recovery.
The default is a fixed delay of 5 seconds.
recoveryBackOffDelayPolicy in interface EnvironmentBuilderpublic EnvironmentBuilder topologyUpdateBackOffDelayPolicy(BackOffDelayPolicy topologyUpdateBackOffDelayPolicy)
EnvironmentBuilderBackOffDelayPolicy 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.
topologyUpdateBackOffDelayPolicy in interface EnvironmentBuilderpublic EnvironmentBuilder addressResolver(AddressResolver addressResolver)
EnvironmentBuilderAddressResolver 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 is guest, and no
address resolver has been provided. The client will then always tries to connect to
localhost to facilitate local development. Just provide a pass-through address resolver
to avoid this behavior, e.g.:
Environment.builder() .addressResolver(address -> address) .build();
addressResolver in interface EnvironmentBuilderpublic EnvironmentBuilder maxProducersByConnection(int maxProducersByConnection)
EnvironmentBuilderDefault is 256, which is the maximum value.
The limit may not be strictly enforced in case of too many concurrent creations.
maxProducersByConnection in interface EnvironmentBuilderpublic EnvironmentBuilder maxTrackingConsumersByConnection(int maxTrackingConsumersByConnection)
EnvironmentBuilderDefault is 50, which is the maximum value.
The limit may not be strictly enforced in case of too many concurrent creations.
maxTrackingConsumersByConnection in interface EnvironmentBuilderpublic EnvironmentBuilder maxConsumersByConnection(int maxConsumersByConnection)
EnvironmentBuilderDefault is 256, which is the maximum value.
The limit may not be strictly enforced in case of too many concurrent creations.
maxConsumersByConnection in interface EnvironmentBuilderpublic EnvironmentBuilder lazyInitialization(boolean lazy)
EnvironmentBuilderNo connection will be open before it is necessary (for stream management or producer/consumer creation).
Default is false.
lazyInitialization in interface EnvironmentBuilderpublic EnvironmentBuilder forceReplicaForConsumers(boolean forceReplica)
EnvironmentBuilderThe 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 EnvironmentBuilder.recoveryBackOffDelayPolicy(BackOffDelayPolicy) and EnvironmentBuilder.topologyUpdateBackOffDelayPolicy(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.
forceReplicaForConsumers in interface EnvironmentBuilderforceReplica - whether to force the connection to a replica or notEnvironmentBuilder.recoveryBackOffDelayPolicy(BackOffDelayPolicy),
EnvironmentBuilder.topologyUpdateBackOffDelayPolicy(BackOffDelayPolicy)public EnvironmentBuilder.TlsConfiguration tls()
EnvironmentBuildertls in interface EnvironmentBuilderpublic EnvironmentBuilder.NettyConfiguration netty()
EnvironmentBuildernetty in interface EnvironmentBuilderpublic EnvironmentBuilder observationCollector(ObservationCollector<?> observationCollector)
EnvironmentBuilderObservationCollector.observationCollector in interface EnvironmentBuilderpublic Environment build()
EnvironmentBuilderEnvironment instance.build in interface EnvironmentBuilderCopyright © 2024 Broadcom Inc. and/or its subsidiaries. All rights reserved.