forked from rabbitmq/rabbitmq-tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew_task.dart
More file actions
24 lines (19 loc) · 708 Bytes
/
new_task.dart
File metadata and controls
24 lines (19 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import "package:dart_amqp/dart_amqp.dart";
void main(List<String> arguments) {
ConnectionSettings settings = new ConnectionSettings(
host: "localhost"
);
Client client = new Client(settings: settings);
String consumeTag = "task_queue";
String msg = arguments.isEmpty ? "Hello World!" : arguments[0];
MessageProperties properties = new MessageProperties.persistentMessage();
client
.channel()
.then((Channel channel) =>
channel.queue(consumeTag, durable: true))
.then((Queue queue) {
queue.publish(msg, properties: properties);
print(" [x] Sent ${msg}");
return client.close();
});
}