Expand description
§Knien
Typed RabbitMQ interfacing for async
Rust.
This crate defines several types of channels for interfacing with RabbitMQ in various ways:
DirectChannel
: a channel for publishing messages on direct queues.TopicChannel
: a channel for publishing messages on topic exchangesRpcChannel
: a channel for publishing messages on direct queues, allowing for receiving replies. It also supports publishing an initial message on a direct queue, and setting up a back-and-forth communincation channel.
RpcChannel
s currently require the tokio
runtime to spawn tasks that receive messages and is therefore behind the rpc
feature flag.
Each channel exposes methods to instantiate Publisher
s and Consumer
s, each of which are generic over the bus they publish on or consume from. These buses define what types of payload they send, so Publisher
s and Consumer
s can take care of serializing and deserializing the payloads and make sure the payloads they publish and yield are of the correct types.
There are several kinds of typed buses, each tied to one of the Channels:
DirectBus
: a bus that defines aPublishPayload
type, a formatter for direct queue names, and the type of argument to that formatter.DirectBus
es are used to simply publish messages on a direct queue without expecting any response.DirectBus
es are tied to theDirectChannel
.TopicBus
: a bus that defines aPublishPayload
type, a topic, and anExchange
.TopicBus
es are used to publish and consume messages from a topic exchange.TopicBus
es are tied to theTopicChannel
.RpcBus
: act like aDirectBus
, but further defines aReplyPayload
type and allows for awaiting replies on sent messages.RpcBus
es are tied to theRpcChannel
RpcCommBus
: a bus that definesInitialPayload
,BackPayload
andForthPayload
, and support flows where a single initial message is sent, after which back-and-forth a communication over which multiple messages can be sent is setup.RpcCommBus
es are tied to theRpcChannel
Macros§
- direct_
bus - Declare a new DirectBus.
- rpc_bus
- Declare a new RpcBus.
- rpc_
comm_ bus - Declare a new RpcCommBus.
- topic_
bus - Declare a new TopicBus.
- topic_
exchange - Declare a new TopicExchange, specifying its type identifier and name.
Structs§
- Back
Reply - A reply on an RpcCommBus.
- Connection
- A connection to the RabbitMQ broker
- Consumer
- A consumer associated with a Channel and a Bus. Consumers implement futures::Stream, yielding Deliverys that are associated with the Bus.
- Consumer
Routing Key - A Routing key that can be used to consume messages from a TopicBus.
ConsumerRoutingKeys cannot contain
#
and must be at least as concrete as TopicBus::TOPIC_PATTERN. - Delivery
- A message that contains a payload associated with a bus
- Direct
Channel - A channel for publishing messages on direct queues.
- Forth
Reply - A reply on an RpcCommBus.
- Publisher
- A publisher associated with a Channel and a Bus. Publishers allow for publishing messages with payloads of the Bus::PublishPayload type. Publishers take care of serializing the payloads before publishing.
- Publisher
Routing Key - A Routing key that can be used to publish messages on a TopicBus. Can only represent concrete routing keys, i.e. routing keys cannot contain wildcards.
- Reply
- A reply to a Delivery that was sent onto a RpcBus
- RpcChannel
- A channel for publishing messages on direct queues, allowing for receiving replies using RpcBus. It also supports publishing an initial message on a direct queue, and setting up a back-and-forth communincation channel using RpcCommBus.
- Topic
Channel - A Topic Channel associated with a TopicExchange.
Enums§
- Error
- This type represents anything that can go wrong when interacting with knien.
- Reply
Error - Error replying to a message. These errors should not occur if only knien-based application interact with the RabbitMQ broker
- Routing
KeyError - Error indicating what went wrong in setting up a ConsumerRoutingKey or a PublisherRoutingKey
Traits§
- Bus
- A Bus. Base trait for several other buses.
This trait is best implemented by using one of the
*_bus!
macros this crate provices. If you are going to implement this trait manually, make sure you associate the correct Channel type to Bus::Chan: - Channel
- A RrabbitMQ channel
- Direct
Bus - A bus that allows publishing on a direct queue.
- RpcBus
- A bus that allows publishing messages on a direct queue, as well as replying to them.
- RpcComm
Bus - An RPC-based communication bus that defines an
InitialPayload
, aBackPayload
andForthPayload
, and supports flows where a single initial message is sent, after which back-and-forth a communication over which multiple messages can be sent is setup. - Topic
Bus - A bus that is associated with a TopicExchange, and defines a pattern of topics onto which messages can be publised and consumed
- Topic
Exchange - A Topic Exchange