欢迎进入Java社区论坛,与200万技术人员互动交流 >>进入 // get方式主动消费 GetResponse res=channel.basicGet(queue_name, false); if (res != null res.getMessageCount() = 0) { System.out.println(res.getMessageCount()); String message
欢迎进入Java社区论坛,与200万技术人员互动交流 >>进入
// get方式主动消费
GetResponse res=channel.basicGet(queue_name, false);
if (res != null && res.getMessageCount() >= 0)
{
System.out.println(res.getMessageCount());
String message = "";
message = new String(res.getBody());
channel.basicAck(res.getEnvelope()。getDeliveryTag(), false);
System.out.println(" [x] Received '" + message + "'");
}
else
{
System.out.println("消息队列中没有可消费的信息!");
break;
}
}
channel.close();
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
在开发的过程中,主要报的异常是:
1.创建交换机和消息队列时,设置的属性和消息产生端的php代码设置的不一样,导致不匹配和一直重写属性
2.在调用时一直没有确定到底是用basicConsume的消费模式还是basicGet消费模式(前者带有监控效果,后者没有,不知道是不是因为一者有跳出while循环,一者没有的原因)
[1] [2]

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Atom editor mac version download
The most popular open source editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use