
mq队列深度为0
mq队列深度为0
/
public static void clear(String queueName) {
try {
Connection connection = getConnection();
Channel channel = connectioncreateChannel();
channelqueuePurge(queueName);
channelclose();
connectionclose();
} catch (IOException e) {
eprintStackTrace();
} catch (TimeoutException e) {
eprintStackTrace();
}
}
/
获取消息
@param queueName 队列名称
/
public static String getMsg(String queueName) {
try {
Connection connection = getConnection();
Channel channel = connectioncreateChannel();
GetResponse response = channelbasicGet(queueName, false);
if (response == null) {
return null;
}
byte[] body = responsegetBody();
long deliveryTag = responsegetEnvelope()getDeliveryTag();
channelbasicAck(deliveryTag, false);
channelclose();
connectionclose();
return new String(body, \"utf-8\");
} catch (IOException e) {
eprintStackTrace();
return null;
} catch (TimeoutException e) {
eprintStackTrace();
return null;
}
}
}
以上就是关于RabbitMQ 消息状态全部的内容,包括:RabbitMQ 消息状态、聊聊RocketMQ(一)、阿里云消息中间件(MQ)探秘等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)