【发布时间】:2015-02-22 04:55:52
【问题描述】:
您好,我在我的 java 应用程序中使用 rabbitMQ。当我停止应用程序时,我需要确保在停止应用程序之前停止队列侦听器(停止从队列接收消息)。 我不确定是否需要调用 channel.close() 或 channel.basicCancel("tag")。 编写以下代码以停止队列侦听。
if(myContext.myChannel.isOpen()){
//myChannel is the one I am using to listen to queue
myContext.myChannel.basicCancel("OP");
//myContext.myChannel.close();
}else{
return ok("Channel is not open");
}
【问题讨论】:
-
如果您需要帮助,请显示一些代码。阅读手册。
-
在停止我的应用程序时我在下面的代码
if(myContext.myChannel.isOpen()){ //myChannel is the one I am using to listen to queue myContext.myChannel.basicCancel("OP"); //myContext.myChannel.close(); }else{ return ok("Channel is not open"); } -
嗨 Manoj,我也面临同样的问题,你能帮我获取“myContext”对象吗?如果你分享对我有很大帮助的代码。谢谢
标签: java rabbitmq message-queue