Crabbit::Environment
Owns Stream connections and creates producers, consumers, and management requests.
An environment lazily creates and reuses connections according to the current stream metadata. Closing it also closes all producers, consumers, super-stream resources, and pooled connections created through it.
environment = Crabbit::Environment.connect(
"rabbitmq-stream://guest:guest@localhost:5552/%2f"
)
begin
environment.create_stream("events") unless environment.stream_exists?("events")
ensure
environment.close
end
Constructors
Parses uri and returns an environment.
Named options are forwarded to Configuration.parse.
Creates an environment without opening a connection.
Connections are established lazily by management and messaging methods. Pass a custom registry to replace or extend sub-entry compression codecs.
Instance methods
Creates a pull consumer for stream.
Retrieve deliveries with Consumer#receive, Consumer#receive?, or
Consumer#each.
Creates a callback consumer for stream.
The block runs on handler fibers and each delivery is marked processed after the block returns, even when it raises.
Creates stream with the supplied retention and placement options.
Raises BrokerError when RabbitMQ rejects the operation, including when
the stream already exists.
Creates a super stream from matching partition and binding-key lists.
Each partition must have a corresponding binding key. arguments are passed to RabbitMQ unchanged.
Returns metadata for every requested stream in input order.
Per-stream failures are represented by StreamMetadata#response_code.
Returns the ordered partition stream names of super_stream.
Creates a producer for stream.
Returns the stored consumer offset, or nil when none exists.
Returns the last publishing ID recorded for a named publisher.
RabbitMQ returns zero when no publisher sequence exists.
Resolves a relative or timestamp offset to an absolute stream offset.
properties are forwarded to RabbitMQ's Resolve Offset Specification command and are useful for broker extensions.
Returns the partitions selected by routing_key and broker bindings.
Stores offset for the consumer reference and stream.
Returns whether stream currently exists.
Errors other than ResponseCode::StreamDoesNotExist are raised.