发送端:
channel.exchangeDeclare(EXCHANGE_NAME, "topic");//声明topic类型的Exchange
String routingKeyOne = "logs.error.one";// 定义一个路由名为“error”
for (int i = 0; i <= 1; i++) {
String messageOne = "this is one error logs:" + i;
channel.basicPublish(EXCHANGE_NAME, routingKeyOne, null, messageOne.getBytes());
System.out.println(" [x] Sent '" + routingKeyOne + "':'"+ messageOne + "'");
}
System.out.println("################################");
String routingKeyTwo = "logs.error.two";
for (int i = 0; i <= 2; i++) {
String messageTwo = "this is two error logs:" + i;
channel.basicPublish(EXCHANGE_NAME, routingKeyTwo, null, messageTwo.getBytes());
System.out.println(" [x] Sent '" + routingKeyTwo + "':'" +