本文整理汇总了Java中com.rabbitmq.client.Channel.basicCancel方法的典型用法代码示例。如果您正苦于以下问题:Java Channel.basicCancel方法的具体用法?Java Channel.basicCancel怎么用?Java Channel.basicCancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rabbitmq.client.Channel
的用法示例。
在下文中一共展示了Channel.basicCancel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: close
import com.rabbitmq.client.Channel; //导入方法依赖的package包/类
private void close(Connection connection, Channel channel) {
try {
if (channel != null && channel.isOpen()) {
if (this.consumerTag != null) {
channel.basicCancel(this.consumerTag);
this.consumerTag = null;
}
log.info("Closing RabbitMQ Channel - " + this.serverIP);
channel.close();
this.channel = null;
}
if (connection != null && connection.isOpen()) {
log.info("Closing RabbitMQ Connection - " + this.serverIP);
connection.close(CLOSE_CONNECTION_TIMEOUT);
this.connection = null;
}
} catch (Exception e) {
log.error("Failed to close RabbitMQ connections " + this.serverIP, e);
}
}
示例2: unsubscribe
import com.rabbitmq.client.Channel; //导入方法依赖的package包/类
@Override
public void unsubscribe(final UUID subscriberId, final EventSubscriber subscriber) throws EventBusException {
try {
final String classname = subscriber.getClass().getName();
final String queueName = UUID.nameUUIDFromBytes(classname.getBytes()).toString();
final Ternary<String, Channel, EventSubscriber> queueDetails = s_subscribers.get(queueName);
final Channel channel = queueDetails.second();
channel.basicCancel(queueName);
s_subscribers.remove(queueName, queueDetails);
} catch (final IOException e) {
throw new EventBusException("Failed to unsubscribe from event bus due to " + e.getMessage(), e);
}
}