A native dart AMQP client supporting version 0.9.1 of the AMQP protocol. It features an asynchronous API, pluggable authentication providers and TLS support.
Package selection guidance compiled from public package information, community data, and project usage.
dart_amqp is a native Dart client for the AMQP 0.9.1 protocol, enabling real-time communication in Dart applications. It provides an asynchronous API for efficient message handling, supports TLS encryption for secure connections, and allows pluggable authentication mechanisms. Ideal for integrating with message brokers like RabbitMQ, it facilitates reliable, low-latency messaging across platforms.
Use cases
Real-time messaging systems
IoT device communication
Event-driven backend services
Live streaming data pipelines
Microservices coordination
Key features
AMQP 0.9.1 protocol support
Asynchronous API design
TLS encryption
Pluggable authentication
Cross-platform compatibility
Suitable for
Developers building real-time apps
Teams using RabbitMQ
Applications requiring secure messaging
Backend services needing event routing
Multi-platform Dart projects
Considerations
Requires AMQP broker (e.g., RabbitMQ)
Limited to AMQP 0.9.1
Authentication setup required
Not suitable for non-real-time use cases
No built-in message persistence
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
dart_amqp
Dart AMQP client implementing protocol version 0.9.1
supports PLAIN and AMQPLAIN authentication providers while other authentication schemes can be plugged in by implementing the appropriate interface.
implements the entire 0.9.1 protocol specification (except basic get and recover-async).
supports both plain-text and TLS connections.
supports publish confirmations.
supports heartbeats.
Things not working yet:
the driver does not currently support recovering client topologies when re-establishing connections. This feature may be implemented in a future version.
Quick start
Listening to a queue:
import"package:dart_amqp/dart_amqp.dart";
voidmain() async {
Client client = Client();
Channel channel = await client.channel(); // auto-connect to localhost:5672 using guest credentialsQueue queue = await channel.queue("hello");
Consumer consumer = await queue.consume();
consumer.listen((AmqpMessage message) {
// Get the payload as a stringprint(" [x] Received string: ${message.payloadAsString}");
// Or unserialize to jsonprint(" [x] Received json: ${message.payloadAsJson}");
// Or just get the raw data as a Uint8Listprint(" [x] Received raw: ${message.payload}");
// The message object contains helper methods for// replying, ack-ing and rejecting
message.reply("world");
});
}
Sending messages via an exchange:
import"package:dart_amqp/dart_amqp.dart";
voidmain() async {
// You can provide a settings object to override the// default connection settingsConnectionSettings settings = ConnectionSettings(
host: "remote.amqp.server.com",
authProvider: PlainAuthenticator("user", "pass")
);
Client client = Client(settings: settings);
Channel channel = await client.channel();
Exchange exchange = await channel.exchange("logs", ExchangeType.FANOUT);
// We dont care about the routing key as our exchange type is FANOUT
exchange.publish("Testing 1-2-3", null);
client.close();
}
This example illustrates how to get a basic RPC server/client up and running using just the provided api calls.
The driver does not provide any helper classes for easily performing RPC calls over AMQP as not everyone needs this
functionality. If you need RPC support for your application you may want to consider using the dart_amqp_rpc package.
Examples
The example folder contains implementations of the six RabbitMQ getting started tutorials.