当前位置: 首页>>代码示例>>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;未经允许,请勿转载。