1. 程式人生 > >RabbitMQ常見錯誤1

RabbitMQ常見錯誤1

java.lang.IllegalStateException: Invalid configuration: 'exchange' must be non-null. at com.rabbitmq.client.impl.AMQImpl$Basic$Publish.<init>(AMQImpl.java:2278) at com.rabbitmq.client.AMQP$Basic$Publish$Builder.build(AMQP.java:1219) at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:691)

at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:668) at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:658) at com.rabbitmq.client.impl.recovery.AutorecoveringChannel.basicPublish(AutorecoveringChannel.java:192) at com.xuecheng.test.rabbitmq.RabbitMqProducerTest.main(RabbitMqProducerTest.java:60)

// 傳送訊息/*    String var1, String var2, BasicProperties var3, byte[] var4    引數明細:        1.交換機:如果不指定將使用mq的預設交換機,(設定為 '')        2.路由key,交換機根據路由key來將訊息轉發到指定的佇列,如果使用預設交換機,routingkey設定為佇列的名稱        3.訊息的屬性        4.訊息內容 */String message = "Hello,RabbitMQ...學成線上";channel.basicPublish(null,QUEUE,null,message.getBytes());// 如果不設定交換機,會使用預設的交換機,不能設定為null
System.out.println("send mq:"+message);