amqpsy-0.0.1 has been yanked.
Visit the last successful build:
amqpsy-0.1.0
Built on top of lapin - this library is designed to be a simple and easy to use AMQP PubSub library.
It's extremely opinionated and comes with some batteries* included.
Features
- Publishers with default configurations for Events and Commands.
- Consumers have DLQ enabled by default.
- Fluent interface for consumer groups.
- Ergonomic error handling API: retry, DLQ, or invalid message options.
- Enforces Protobuf for messages, ensuring backward compatibility.
- Distributed tracing enabled with Otel: linked traces from publisher to consumer.
Usage
Consumer Groups
let context = new; // your app context
let config = AmqpConfig ;
builder
.for_topic_exchange
// Using default settings
.consume.await?
// Using custom settings
.consume_with_config.await?
.then
.for_topic_exchange
.consume.await?
.consume.await?
.consume.await?
.consume.await?
.run_until_shutdown.await?; // This will block until shutdown
// Example handler
;
Publishers
Pick one of three option using the AmqpPublisher::new_* methods.
- Command: Publisher confirm and mandatory routing enabled
- Event: Publisher confirm enabled but no mandatory routing enabled
- Event without Publisher confirmation: No publisher confirm and no mandatory routing
// commands::CreateOutboundTransaction is a Proto message
let command =
new_for_command
.await?;
let event = new_for_event
.await?; // or new_for_event_without_publisher_confirmation
// Publish a command
// Command has publisher confirm and mandatory routing enabled
command.publish.await?;
// Publish an event
// Event has publisher confirm enabled but no mandatory routing enabled
event.publish.await?;
Distributed Tracing
Traces are linked between publisher and consumer with necessary tags set on them (prefixed with amqpsy.*)