当前位置: 首页>>代码示例>>Java>>正文


Java Channel.isOpen方法代码示例

本文整理汇总了Java中com.rabbitmq.client.Channel.isOpen方法的典型用法代码示例。如果您正苦于以下问题:Java Channel.isOpen方法的具体用法?Java Channel.isOpen怎么用?Java Channel.isOpen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.rabbitmq.client.Channel的用法示例。


在下文中一共展示了Channel.isOpen方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
    }
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:21,代码来源:RabbitMQClient.java

示例2: execute

import com.rabbitmq.client.Channel; //导入方法依赖的package包/类
/**
 * Do something with a pooled channel (similar to Spring JDBC TransactionTemplate#execute)
 */
private <T> T execute(ChannelCallback<T> callback) throws Exception {
    Channel channel;
    try {
        channel = channelPool.borrowObject();
    } catch (IllegalStateException e) {
        // Since this method is not synchronized its possible the
        // channelPool has been cleared by another thread
        checkConnectionAndChannelPool();
        channel = channelPool.borrowObject();
    }
    if (!channel.isOpen()) {
        log.warn("Got a closed channel from the pool");
        // Reconnect if another thread hasn't yet
        checkConnectionAndChannelPool();
        channel = channelPool.borrowObject();
    }
    try {
        return callback.doWithChannel(channel);
    } finally {
        channelPool.returnObject(channel);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:RabbitMQProducer.java

示例3: closeChannel

import com.rabbitmq.client.Channel; //导入方法依赖的package包/类
private void closeChannel(Channel channel) throws IOException, TimeoutException {
	try {
		if (channel != null && channel.isOpen()) {
			channel.close();
		}
	} catch (Exception e) {
		logger.warn("RabbitMQ channel erred on close",
				new ContextedRuntimeException(e)
						.addContextValue("queueName", queueName)
						.addContextValue("connectionFactory",
						ToStringBuilder.reflectionToString(connectionFactory)));
	}
}
 
开发者ID:BreakTheMonolith,项目名称:btm-DropwizardHealthChecks,代码行数:14,代码来源:RabbitMQHealthCheck.java

示例4: getChannel

import com.rabbitmq.client.Channel; //导入方法依赖的package包/类
/**
 * Get a {@link Channel} for the specified key. If the key does not exist then a channel is created.
 * <p>
 * Note: Do not cache the returned Channel, as it could become invalid if the underlying connection is closed. The key is
 * usually an object that's requiring a channel.
 * <p>
 * @param key client specific key, usually a reference to themselves
 * <p>
 * @return Channel for this key, can change over time
 */
public synchronized Channel getChannel( Object key )
{
    Channel channel = null;
    do {
        channel = channels.computeIfAbsent( key, k
                                            -> {
                                        try {
                                            LOG.log( Level.FINE, "creating channel" );
                                            return getConnection().
                                                    createChannel();
                                        }
                                        catch( IOException ex ) {
                                            throw new UncheckedIOException( ex );
                                        }
                                    } );
        if( channel != null && !channel.isOpen() ) {
            LOG.log( Level.FINE, "discarding dead channel" );

            channels.remove( key );
            channel = null;
        }
    }
    while( channel == null );

    return channel;
}
 
开发者ID:peter-mount,项目名称:opendata-common,代码行数:37,代码来源:RabbitConnection.java

示例5: close

import com.rabbitmq.client.Channel; //导入方法依赖的package包/类
@Override
public void close() {
    final Channel subscriptionChannel = channel.get();
    try {
        if (subscriptionChannel != null && subscriptionChannel.isOpen()) {
            subscriptionChannel.close();
        }
        onClose.accept(this);
    } catch (IOException | TimeoutException e) {
        throw new ChannelException(
                String.format("Error while closing consumer: '%s' channel", consumerTag()), e);
    }
}
 
开发者ID:FinderSystems,项目名称:Elmer,代码行数:14,代码来源:RabbitSubscriptionManager.java

示例6: validateObject

import com.rabbitmq.client.Channel; //导入方法依赖的package包/类
@Override
public boolean validateObject(Channel t) {
    return t.isOpen();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:PoolableChannelFactory.java


注:本文中的com.rabbitmq.client.Channel.isOpen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。