我在同一臺機器上有一個生產者和經紀人。生產者發送如下消息:rabbitmq amqp - 收聽來自消費者的ack消息
channel = connection.createChannel();
//Create a durable queue (if not already present)
channel.queueDeclare(merchantId, true, false, false, null);
//Publish message onto the queue
channel.basicPublish("", consumerId, true, false,
MessageProperties.MINIMAL_PERSISTENT_BASIC, "myMessage");
消費者坐在另一臺機器上並收聽消息。它採用明確承認,像這樣:
while (true) {
QueueingConsumer.Delivery delivery = consumer.nextDelivery();
//Handle message here
channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
}
從我的理解中,ACK是爲券商出隊的消息。
但是我的生產者怎麼才能知道消費者發送的消息?