Package com.rabbitmq.stream
Interface Environment
-
- All Superinterfaces:
AutoCloseable
public interface Environment extends AutoCloseable
TheEnvironment
is the main entry point to a node or a cluster of nodes.Producer
andConsumer
instances are created from anEnvironment
instance. AnEnvironment
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 anEnvironment
instance.Environment
instances are expected to be thread-safe.- See Also:
EnvironmentBuilder
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static EnvironmentBuilder
builder()
Create a builder to configure and create anEnvironment
void
close()
Close the environment and its resources.ConsumerBuilder
consumerBuilder()
Create aConsumerBuilder
to configure and create aConsumer
void
deleteStream(String stream)
Delete a streamvoid
deleteSuperStream(String superStream)
Delete a super stream.ProducerBuilder
producerBuilder()
Create aProducerBuilder
to configure and create aProducer
.StreamStats
queryStreamStats(String stream)
Query statistics on a stream.void
storeOffset(String reference, String stream, long offset)
Store the offset for a given reference on the given stream.StreamCreator
streamCreator()
Return aStreamCreator
to configure and create a stream.boolean
streamExists(String stream)
Return whether a stream exists or not.
-
-
-
Method Detail
-
builder
static EnvironmentBuilder builder()
Create a builder to configure and create anEnvironment
- Returns:
- the environment builder
- See Also:
EnvironmentBuilder
-
streamCreator
StreamCreator streamCreator()
Return aStreamCreator
to configure and create a stream.- Returns:
- the stream creator
- See Also:
StreamCreator
-
deleteStream
void deleteStream(String stream)
Delete a stream- Parameters:
stream
- the stream to delete- Since:
- 0.15.0
-
deleteSuperStream
void deleteSuperStream(String superStream)
Delete a super stream.Requires RabbitMQ 3.13.0 or more.
- Parameters:
superStream
- the super stream to delete
-
queryStreamStats
StreamStats queryStreamStats(String stream)
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
void storeOffset(String reference, String stream, long offset)
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:
Consumer.store(long)
,MessageHandler.Context.storeOffset()
-
streamExists
boolean streamExists(String stream)
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_OK
orConstants.RESPONSE_CODE_STREAM_DOES_NOT_EXIST
-
producerBuilder
ProducerBuilder producerBuilder()
Create aProducerBuilder
to configure and create aProducer
.- Returns:
- the producer builder
- See Also:
ProducerBuilder
-
consumerBuilder
ConsumerBuilder consumerBuilder()
Create aConsumerBuilder
to configure and create aConsumer
- Returns:
- the consumer builder
- See Also:
ConsumerBuilder
-
close
void close()
Close the environment and its resources.- Specified by:
close
in interfaceAutoCloseable
-
-