Java Code Examples for com.rabbitmq.client.ShutdownSignalException#isInitiatedByApplication()

The following examples show how to use com.rabbitmq.client.ShutdownSignalException#isInitiatedByApplication() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RabbitMQEventBus.java    From cloudstack with Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example 2
Source File: ChannelHandler.java    From lyra with Apache License 2.0 6 votes vote down vote up
@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) {
          }
        }
      });
  }
}
 
Example 3
Source File: RabbitMQConsumer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Called when either the channel or the underlying connection has been shut down.
 *
 * @param consumerTag the consumer tag associated with the consumer
 * @param signal      a {@link ShutdownSignalException} indicating the reason for the shut down
 */
@Override
public void handleShutdownSignal(String consumerTag, ShutdownSignalException signal) {
    if (signal.isInitiatedByApplication()) {
        log.info("The connection to the messaging server was shut down. Consumer tag: " + consumerTag);

    } else if (signal.getReference() instanceof Channel) {
        int channelNumber = ((Channel) signal.getReference()).getChannelNumber();
        log.info("The consumer on channel number: " + channelNumber + " with consumer tag: " + consumerTag
                + " was shut down.");

    } else {
        log.info("The consumer with consumer tag: " + consumerTag + " was shut down.");
    }
}
 
Example 4
Source File: RoboconfConsumer.java    From roboconf-platform with Apache License 2.0 5 votes vote down vote up
@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 ));
	}
}
 
Example 5
Source File: Exceptions.java    From lyra with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 6
Source File: LoggingShutdownListener.java    From elasticactors with Apache License 2.0 4 votes vote down vote up
@Override
public void shutdownCompleted(ShutdownSignalException e) {
    if (!e.isInitiatedByApplication()) {
        logger.error("Channel shutdown detected", e);
    }
}