本文整理汇总了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);
}
}
示例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);
}
}
示例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) {
}
}
});
}
}
示例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);
}
}
示例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;
}
}
示例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();
}
}
}
}
}
示例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);
}
示例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 ));
}
}
示例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;
}
}
}
}
}
示例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;
}
示例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;
}
示例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;
}