dart_amqp_client
AMQP (उन्नत संदेश भंडारण प्रोटोकॉल) कनेक्शन, चैनल और संबंधित कॉलबैक के संभालने को सरल बनाने वाला डार्ट पैकेज।
AMQP (उन्नत संदेश भंडारण प्रोटोकॉल) कनेक्शन, चैनल और संबंधित कॉलबैक के हैंडलिंग को सरल बनाने वाला Dart पैकेज। यह AMQP सर्वर के साथ कनेक्शन स्थापित और प्रबंधित करने के लिए एक आसान उपयोगी इंटरफ़ेस प्रदान करता है, जिससे आप निम्न-स्तरीय AMQP विवरणों के बारे में चिंता किए बिना अपने एप्लिकेशन के तर्क पर ध्यान केंद्रित कर सकते हैं।
यह अंग्रेज़ी मूल स्नैपशॉट है। नवीनतम सामग्री GitHub पर देखें।
Dart AMQP Client is a Dart package that simplifies the handling of AMQP (Advanced Message Queuing Protocol) connections, channels, and associated callbacks.
Connection Management: Automatically handles AMQP connection establishment and reconnection. Callback Support: Define custom callbacks for connection events, such as when the connection is established or encounters an error. Reconnection Control: Configure the maximum number of reconnection attempts for robust AMQP connections. Simple Integration: Easily integrate the package into your Dart applications with a straightforward API.
To use this package, add dart_amqp_client as a dependency in your pubspec.yaml file:
dependencies: dart_amqp_client: ^1.0.1
Then, run pub get to fetch and install the package.
import 'package:dart_amqp_client/dart_amqp_client.dart';
void main() {
// Create a ConnectionSettings instance with your AMQP server details.
ConnectionSettings connectionSettings = ConnectionSettings(
host: 'localhost',
port: 5672,
maxConnectionAttempts: 5, // Set the maximum connection attempts
);
// Create an instance of the AMQP service.
AmqpService(connectionSettings);
// Set callback functions for connection events.
AmqpService.onConnected(() {
print('Connected to AMQP server.');
// Use the service to establish an AMQP connection.
Client client = AmqpService.getClient();
// ... Perform AMQP operations with the client and channel ...
String consumeTag = "hello";
String msg = "Hello World!";
client.channel().then((Channel channel) {
return channel.queue(consumeTag, durable: false);
}).then((Queue queue) {
queue.publish(msg);
print(" [x] Sent $msg");
client.close();
});
String queueTag = "hello";
Channel? channel = AmqpService.getChannel();
channel!.queue(queueTag, durable: false).then((Queue queue) {
print(" [*] Waiting for messages in $queueTag. To Exit press CTRL+C");
return queue.consume(consumerTag: queueTag, noAck: true);
}).then((Consumer consumer) {
consumer.listen((AmqpMessage event) {
print(" [x] Received ${event.payloadAsString}");
});
});
});
AmqpService.onDisconnected(() {
print('Disconnected from AMQP server.');
});
AmqpService.onError((Exception error) {
print('An error occurred: $error');
});
}
The [example] folder contains implementations for getting started
Feel free to contribute
dart_amqp is distributed under the [MIT license]