这是播放框架中用于发布消息的scala代码。一切顺利,直到我重新启动播放服务器。当我重新启动播放服务器时,客户端会立即退出。
val connection = RabbitMQConnection.getConnection(uri)
val channel = connection.createChannel()
channel.queueDeclare( QUEUE_NAME, true, false, false, null)
channel.basicPublish("", QUEUE_NAME,true,
MessageProperties.PERSISTENT_TEXT_PLAIN,
cmdLine.getBytes("UTF-8"))
这是预期的行为吗?有修复吗? 以下是客户端代码:
ConnectionFactory factory = new ConnectionFactory();
factory.setUri(rabbitmq_uri);
factory.setRequestedHeartbeat(30);
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
channel.queueDeclare(QUEUE_NAME, true, false, false, null);
channel.basicQos(1);
Consumer consumer = getConsumer(channel);
boolean autoAck = false;
channel.basicConsume(QUEUE_NAME, autoAck, consumer);