求大神指导~
查看了很多能查到的文档都没有找到明确说明的,rabbit的发布订阅和ActiveMq 的发布订阅有所区别,我之前一直用 ActiveMq 的 后来公司要求改为rabbitMQ,请问同一个队列如果有多个消费者,那么如何确保所有消费者都恩那个收到同一条消息?而不是 消费者1消费掉 如图:
我写的消费者代码如下:
public
void
receiveMessage(String topicName)
{
try
{
Consumer consumer =
new
DefaultConsumer(channel)
{
public
void
handleDelivery(String consumerTag, Envelope envelope,
AMQP.BasicProperties properties,
byte
[] body)
throws
IOException {
//delivery.getEnvelope().getDeliveryTag()消息的标识,false只确认当前一个消息收到,true确认所有consumer获得的消息
channel.basicAck(envelope.getDeliveryTag(),
true
);
HashMap<Integer, LinkedList<Long>> message = (HashMap<Integer, LinkedList<Long>>) toObject(body);
f