當前位置: 首頁>>代碼示例>>Java>>正文


Java ShutdownSignalException.isInitiatedByApplication方法代碼示例

本文整理匯總了Java中com.rabbitmq.client.ShutdownSignalException.isInitiatedByApplication方法的典型用法代碼示例。如果您正苦於以下問題:Java ShutdownSignalException.isInitiatedByApplication方法的具體用法?Java ShutdownSignalException.isInitiatedByApplication怎麽用?Java ShutdownSignalException.isInitiatedByApplication使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.rabbitmq.client.ShutdownSignalException的用法示例。


在下文中一共展示了ShutdownSignalException.isInitiatedByApplication方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: shutdownCompleted

import com.rabbitmq.client.ShutdownSignalException; //導入方法依賴的package包/類
@Override
public void shutdownCompleted(final ShutdownSignalException shutdownSignalException) {
    if (!shutdownSignalException.isInitiatedByApplication()) {

        for (final String subscriberId : s_subscribers.keySet()) {
            final Ternary<String, Channel, EventSubscriber> subscriberDetails = s_subscribers.get(subscriberId);
            subscriberDetails.second(null);
            s_subscribers.put(subscriberId, subscriberDetails);
        }

        abortConnection(); // disconnected to AMQP server, so abort the connection and channels
        s_logger.warn("Connection has been shutdown by AMQP server. Attempting to reconnect.");

        // initiate re-connect process
        final ReconnectionTask reconnect = new ReconnectionTask();
        executorService.submit(reconnect);
    }
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:19,代碼來源:RabbitMQEventBus.java

示例2: shutdownCompleted

import com.rabbitmq.client.ShutdownSignalException; //導入方法依賴的package包/類
@Override
public void shutdownCompleted(ShutdownSignalException shutdownSignalException) {
    if (!shutdownSignalException.isInitiatedByApplication()) {

        for (String subscriberId : s_subscribers.keySet()) {
            Ternary<String, Channel, EventSubscriber> subscriberDetails = s_subscribers.get(subscriberId);
            subscriberDetails.second(null);
            s_subscribers.put(subscriberId, subscriberDetails);
        }

        abortConnection(); // disconnected to AMQP server, so abort the connection and channels
        s_logger.warn("Connection has been shutdown by AMQP server. Attempting to reconnect.");

        // initiate re-connect process
        ReconnectionTask reconnect = new ReconnectionTask();
        executorService.submit(reconnect);
    }
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:19,代碼來源:RabbitMQEventBus.java

示例3: shutdownCompleted

import com.rabbitmq.client.ShutdownSignalException; //導入方法依賴的package包/類
@Override
public void shutdownCompleted(ShutdownSignalException e) {
  channelShutdown();
  if (!e.isInitiatedByApplication()) {
    log.error("Channel {} was closed unexpectedly", ChannelHandler.this);
    lastShutdownSignal = e;
    if (!Exceptions.isConnectionClosure(e) && canRecover())
      ConnectionHandler.RECOVERY_EXECUTORS.execute(new Runnable() {
        @Override
        public void run() {
          try {
            recoveryPending.set(true);
            recoverChannel(false);
          } catch (Throwable ignore) {
          }
        }
      });
  }
}
 
開發者ID:jhalterman,項目名稱:lyra,代碼行數:20,代碼來源:ChannelHandler.java

示例4: handleShutdownSignal

import com.rabbitmq.client.ShutdownSignalException; //導入方法依賴的package包/類
@Override
public void handleShutdownSignal(String consumerTag, ShutdownSignalException sig) {
    if (sig.isInitiatedByApplication()) {
        LOGGER.info("Handled shutdown signal");
    } else {
        LOGGER.error("Handled shutdown signal", sig);
    }
}
 
開發者ID:anderelate,項目名稱:storm-rabbitmq,代碼行數:9,代碼來源:AutorecoverableQueueingConsumer.java

示例5: primitiveCall

import com.rabbitmq.client.ShutdownSignalException; //導入方法依賴的package包/類
private byte[] primitiveCall( AMQP.BasicProperties props, byte[] message )
        throws IOException,
               ShutdownSignalException,
               TimeoutException
{
    checkConsumer();
    BlockingCell<Object> k = new BlockingCell<>();

    String replyId = RabbitMQ.newCorrelationId();
    props = ((props == null) ? new AMQP.BasicProperties.Builder() : props.builder())
            .correlationId( replyId )
            .replyTo( replyQueue )
            .build();
    continuationMap.put( replyId, k );

    publish( props, message );

    Object reply = k.uninterruptibleGet( timeout );
    if( reply instanceof ShutdownSignalException ) {
        ShutdownSignalException sig = (ShutdownSignalException) reply;
        ShutdownSignalException wrapper = new ShutdownSignalException( sig.isHardError(),
                                                                       sig.isInitiatedByApplication(),
                                                                       sig.getReason(),
                                                                       sig.getReference() );
        wrapper.initCause( sig );
        throw wrapper;
    }
    else {
        return (byte[]) reply;
    }
}
 
開發者ID:peter-mount,項目名稱:opendata-common,代碼行數:32,代碼來源:RabbitRPCClient.java

示例6: handleShutdownSignal

import com.rabbitmq.client.ShutdownSignalException; //導入方法依賴的package包/類
/**
 * No-op implementation of {@link Consumer#handleShutdownSignal}.
 */
public void handleShutdownSignal(String consumerTag, ShutdownSignalException sig) {
    log.info("Recieved shutdown signal on the rabbitMQ channel");

    // Check if the consumer closed the connection or something else
    if (!sig.isInitiatedByApplication()) {
        // Something else closed the connection so reconnect
        boolean connected = false;
        while (!connected && !stopping) {
            try {
                reconnect();
                connected = true;
            } catch (IOException | TimeoutException e) {
                log.warn("Unable to obtain a RabbitMQ channel. Will try again");

                Integer networkRecoveryInterval = consumer.getEndpoint().getNetworkRecoveryInterval();
                final long connectionRetryInterval = networkRecoveryInterval != null && networkRecoveryInterval > 0
                        ? networkRecoveryInterval : 100L;
                try {
                    Thread.sleep(connectionRetryInterval);
                } catch (InterruptedException e1) {
                    Thread.currentThread().interrupt();
                }
            }
        }
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:30,代碼來源:RabbitConsumer.java

示例7: shutdownCompleted

import com.rabbitmq.client.ShutdownSignalException; //導入方法依賴的package包/類
@Override
public void shutdownCompleted(ShutdownSignalException cause) {
  if (cause.isInitiatedByApplication()) {
    return;
  }

  log.info("RabbitMQ connection shutdown! The client will attempt to reconnect automatically", cause);
}
 
開發者ID:vert-x3,項目名稱:vertx-rabbitmq-client,代碼行數:9,代碼來源:RabbitMQClientImpl.java

示例8: handleShutdownSignal

import com.rabbitmq.client.ShutdownSignalException; //導入方法依賴的package包/類
@Override
public void handleShutdownSignal( String consumerTag, ShutdownSignalException sig ) {

	if( sig.isInitiatedByApplication()) {
		this.logger.fine( this.sourceName + ": the connection to the messaging server was shut down." + id( consumerTag ));

	} else if( sig.getReference() instanceof Channel ) {
		int nb = ((Channel) sig.getReference()).getChannelNumber();
		this.logger.fine( "A RabbitMQ consumer was shut down. Channel #" + nb + ", " + id( consumerTag ));

	} else {
		this.logger.fine( "A RabbitMQ consumer was shut down." + id( consumerTag ));
	}
}
 
開發者ID:roboconf,項目名稱:roboconf-platform,代碼行數:15,代碼來源:RoboconfConsumer.java

示例9: shutdownCompleted

import com.rabbitmq.client.ShutdownSignalException; //導入方法依賴的package包/類
@Override
public void shutdownCompleted(ShutdownSignalException cause) {
  if (cause != null) {
    Object obj = cause.getReference();
    if (Channel.class.isInstance(obj)) {
      Channel.class.cast(obj).removeShutdownListener(this);
    } else if (Connection.class.isInstance(obj)) {
      Connection.class.cast(obj).removeShutdownListener(this);
    }
    if (clazz.isInstance(obj)) {
      if (clazz == Channel.class) {
        Channel ch = Channel.class.cast(obj);
        if (cause.isInitiatedByApplication()) {
          LOGGER.info(MSG("Channel #{} closed."), ch.getChannelNumber());
        } else {
          LOGGER.info(MSG("Channel #{} suddenly closed."), ch.getChannelNumber());
        }
        if (ch.equals(AMQPSession.this.channel)) {
          AMQPSession.this.channel = null;
        }
      } else if (clazz == Connection.class) {
        Connection conn = Connection.class.cast(obj);
        if (cause.isInitiatedByApplication()) {
          LOGGER.info(MSG("Connection closed."));
        } else {
          LOGGER.info(MSG("Connection suddenly closed."));
        }
        if (conn.equals(AMQPSession.this.connection)) {
          AMQPSession.this.connection = null;
        }
      }
    }
  }
}
 
開發者ID:rinrinne,項目名稱:gerrit-rabbitmq-plugin,代碼行數:35,代碼來源:AMQPSession.java

示例10: isRetryable

import com.rabbitmq.client.ShutdownSignalException; //導入方法依賴的package包/類
private static boolean isRetryable(ShutdownSignalException e) {
  if (e.isInitiatedByApplication())
    return false;
  Method method = e.getReason();
  if (method instanceof AMQP.Connection.Close)
    return isRetryable(((AMQP.Connection.Close) method).getReplyCode());
  if (method instanceof AMQP.Channel.Close)
    return isRetryable(((AMQP.Channel.Close) method).getReplyCode());
  return false;
}
 
開發者ID:jhalterman,項目名稱:lyra,代碼行數:11,代碼來源:Exceptions.java

示例11: shutdownCompleted

import com.rabbitmq.client.ShutdownSignalException; //導入方法依賴的package包/類
/**
 * @inheritDoc
 * @param shutdownSignalException
 *            the exception.
 */
public void shutdownCompleted(ShutdownSignalException shutdownSignalException) {
    if (shutdownSignalException != null && !shutdownSignalException.isInitiatedByApplication()) {
        LOGGER.warning("RabbitMQ connection was suddenly disconnected.");
    }
    notifyOnCloseCompleted();
    connection = null;
}
 
開發者ID:rinrinne,項目名稱:rabbitmq-consumer-plugin,代碼行數:13,代碼來源:RMQConnection.java

示例12: shutdownCompleted

import com.rabbitmq.client.ShutdownSignalException; //導入方法依賴的package包/類
/**
 * @inheritDoc
 * @param shutdownSignalException
 *            the exception.
 */
public void shutdownCompleted(ShutdownSignalException shutdownSignalException) {
    if (shutdownSignalException != null && !shutdownSignalException.isInitiatedByApplication()) {
        LOGGER.warning(MessageFormat.format("RabbitMQ channel {0} was suddenly closed.", channel.getChannelNumber()));
    }
    notifyOnCloseCompleted();
    channel = null;
}
 
開發者ID:rinrinne,項目名稱:rabbitmq-consumer-plugin,代碼行數:13,代碼來源:AbstractRMQChannel.java


注:本文中的com.rabbitmq.client.ShutdownSignalException.isInitiatedByApplication方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。