Package com.rabbitmq.stream
Interface Environment
- All Superinterfaces:
AutoCloseable
The
Environment is the main entry point to a node or a cluster of nodes. Producer
and Consumer instances are created from an Environment instance. An Environment can also create and delete streams.
Applications are supposed to use a single Environment instance to interact with a
cluster.
Use builder() to configure and create an Environment instance.
Environment instances are expected to be thread-safe.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic EnvironmentBuilderbuilder()Create a builder to configure and create anEnvironmentvoidclose()Close the environment and its resources.Create aConsumerBuilderto configure and create aConsumervoiddeleteStream(String stream) Delete a streamvoiddeleteSuperStream(String superStream) Delete a super stream.Create aProducerBuilderto configure and create aProducer.queryStreamStats(String stream) Query statistics on a stream.voidstoreOffset(String reference, String stream, long offset) Store the offset for a given reference on the given stream.Return aStreamCreatorto configure and create a stream.booleanstreamExists(String stream) Return whether a stream exists or not.
-
Method Details
-
builder
Create a builder to configure and create anEnvironment- Returns:
- the environment builder
- See Also:
-
streamCreator
StreamCreator streamCreator()Return aStreamCreatorto configure and create a stream.- Returns:
- the stream creator
- See Also:
-
deleteStream
Delete a stream- Parameters:
stream- the stream to delete- Since:
- 0.15.0
-
deleteSuperStream
Delete a super stream.Requires RabbitMQ 3.13.0 or more.
- Parameters:
superStream- the super stream to delete
-
queryStreamStats
Query statistics on a stream.Requires RabbitMQ 3.11 or more.
- Parameters:
stream- the stream to get statistics from- Returns:
- statistics on the stream
- Throws:
UnsupportedOperationException- if the broker does not support this command
-
storeOffset
Store the offset for a given reference on the given stream.This method is useful to store a given offset before a consumer is created.
Prefer the
Consumer.store(long)orMessageHandler.Context.storeOffset()methods to store offsets while consuming messages.- Parameters:
reference- the reference to store the offset for, e.g. a consumer namestream- the streamoffset- the offset to store- See Also:
-
streamExists
Return whether a stream exists or not.- Parameters:
stream- the stream to check the existence- Returns:
- true if stream exists, false if it does not exist
- Throws:
StreamException- if response code is different fromConstants.RESPONSE_CODE_OKorConstants.RESPONSE_CODE_STREAM_DOES_NOT_EXIST
-
producerBuilder
ProducerBuilder producerBuilder()Create aProducerBuilderto configure and create aProducer.- Returns:
- the producer builder
- See Also:
-
consumerBuilder
ConsumerBuilder consumerBuilder()Create aConsumerBuilderto configure and create aConsumer- Returns:
- the consumer builder
- See Also:
-
close
void close()Close the environment and its resources.- Specified by:
closein interfaceAutoCloseable
-