針對一個消息羣發的場景,最先以爲只有queue接收的方式,那樣只能給每個接受者分配一個queue太不方便了。後來發現還有exchange接收的方式。
發送端:
template.convertAndSend("fanoutExchange","","helllooooooo");
接收端:
client.subscribe("/exchange/fanoutExchange", function(data) {
});
其中fanoutExchange爲fanout類型exchange的名字,這樣的話不再需要關注queue了。