1
我用STOMP package,我寫了一個測試:飛鏢和RabbitMQ的綁定交換
test('can subscribe and send events to mq server',() async {
StompClient client2 = await serverClient.connect(mqIp,
port: mqPort, login: login, passcode: password);
client2.sendJson('Domain changed', {'a':'b'});
client2.disconnect();
StreamController controller = new StreamController();
Stream<String> stream = controller.stream.asBroadcastStream();
StompClient client1 = await serverClient.connect(mqIp,
port: mqPort, login: login, passcode: password);
client1.subscribeString("Entity changed", 'Domain changed',
(Map<String, String> headers, String message) {
controller.add(message);
}, ack: AUTO);
await for (String message in stream) {
String expectedEntity =
'{\"a\":\"b\"}';
expect(message, equals(expectedEntity));
break;
}
client1.unsubscribe("Entity changed");
client1.disconnect();
}, timeout: new Timeout(new Duration(seconds: 6)));
當我運行pub run test
我得到Test timed out
。
在RabbitMQ的梟雄在綁定節,我得到:(Default exchange binding)
和零總共消息:
是否有可能在一個通道發送和recive消息?
如果我在RabbitMQ Managment中使用client1.subscribeString(ack: CLIENT,...)
,我收到一條消息「在內存中」,但仍在測試Test timed out
,我無法從mq獲取消息。
也許我必須建立amq.fanout交換,但我該如何做到這一點?