當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。