com.rabbitmq.client.ShutdownListener Java Examples

The following examples show how to use com.rabbitmq.client.ShutdownListener. 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: RabbitMetricsBinder.java    From summerframework with Apache License 2.0 6 votes vote down vote up
@Override
public void newConnection(final Connection connection) {
    try {
        if (connection.getId() == null) {
            connection.setId(UUID.randomUUID().toString());
        }
        connections.incrementAndGet();
        connectionState.put(connection.getId(), new RabbitMetricsBinder.ConnectionState(connection));
        connection.addShutdownListener(new ShutdownListener() {
            @Override
            public void shutdownCompleted(ShutdownSignalException cause) {
                closeConnection(connection);
            }
        });
    } catch (Exception e) {
        LOGGER.info("Error while computing metrics in newConnection: " + e.getMessage());
    }
}
 
Example #2
Source File: RabbitMetricsBinder.java    From summerframework with Apache License 2.0 6 votes vote down vote up
@Override
public void newChannel(final Channel channel) {
    try {
        channels.incrementAndGet();
        channel.addShutdownListener(new ShutdownListener() {
            @Override
            public void shutdownCompleted(ShutdownSignalException cause) {
                closeChannel(channel);
            }
        });
        connectionState(channel.getConnection()).channelState.put(channel.getChannelNumber(),
            new RabbitMetricsBinder.ChannelState(channel));
    } catch (Exception e) {
        LOGGER.info("Error while computing metrics in newChannel: " + e.getMessage());
    }
}
 
Example #3
Source File: RetryableResource.java    From lyra with Apache License 2.0 6 votes vote down vote up
/**
 * Handles common method invocations.
 */
boolean handleCommonMethods(Object delegate, Method method, Object[] args) throws Throwable {
  if ("abort".equals(method.getName()) || "close".equals(method.getName())) {
    try {
      Reflection.invoke(delegate, method, args);
      return true;
    } finally {
      closed = true;
      afterClosure();
      interruptWaiters();
    }
  } else if ("addShutdownListener".equals(method.getName()) && args[0] != null)
    shutdownListeners.add((ShutdownListener) args[0]);
  else if ("removeShutdownListener".equals(method.getName()) && args[0] != null)
    shutdownListeners.remove((ShutdownListener) args[0]);
  return false;
}
 
Example #4
Source File: RabbitMQConsumer.java    From storm-rabbitmq with MIT License 5 votes vote down vote up
private Connection createConnection() throws IOException, TimeoutException {
  Connection connection = highAvailabilityHosts == null || highAvailabilityHosts.length == 0 
        ? connectionFactory.newConnection() 
        : connectionFactory.newConnection(highAvailabilityHosts);
  connection.addShutdownListener(new ShutdownListener() {
    @Override
    public void shutdownCompleted(ShutdownSignalException cause) {
      logger.error("shutdown signal received", cause);
      reporter.reportError(cause);
      reset();
    }
  });
  logger.info("connected to rabbitmq: " + connection + " for " + queueName);
  return connection;
}
 
Example #5
Source File: ChannelHandler.java    From lyra with Apache License 2.0 5 votes vote down vote up
public ChannelHandler(ConnectionHandler connectionHandler, Channel delegate, Config config) {
  this.connectionHandler = connectionHandler;
  this.delegate = delegate;
  this.config = config;

  ShutdownListener listener = new ChannelShutdownListener();
  shutdownListeners.add(listener);
  delegate.addShutdownListener(listener);
}
 
Example #6
Source File: MockChannel.java    From rabbitmq-mock with Apache License 2.0 4 votes vote down vote up
@Override
public void removeShutdownListener(ShutdownListener listener) {
    throw new UnsupportedOperationException();
}
 
Example #7
Source File: TestChannel.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void addShutdownListener(ShutdownListener listener) {
    throw new UnsupportedOperationException(
            "This method is not currently supported as it is not used by current API in testing");

}
 
Example #8
Source File: TestChannel.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void removeShutdownListener(ShutdownListener listener) {
    throw new UnsupportedOperationException(
            "This method is not currently supported as it is not used by current API in testing");

}
 
Example #9
Source File: TestConnection.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void addShutdownListener(ShutdownListener listener) {
    throw new UnsupportedOperationException(
            "This method is not currently supported as it is not used by current API in testing");
}
 
Example #10
Source File: TestConnection.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void removeShutdownListener(ShutdownListener listener) {
    throw new UnsupportedOperationException(
            "This method is not currently supported as it is not used by current API in testing");
}
 
Example #11
Source File: PoolableChannel.java    From jweb-cms with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void addShutdownListener(ShutdownListener listener) {
    delegate.addShutdownListener(listener);
}
 
Example #12
Source File: PoolableChannel.java    From jweb-cms with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void removeShutdownListener(ShutdownListener listener) {
    delegate.removeShutdownListener(listener);
}
 
Example #13
Source File: TestChannel.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void addShutdownListener(ShutdownListener listener) {
    throw new UnsupportedOperationException("This method is not currently supported as it is not used by current API in testing");

}
 
Example #14
Source File: TestChannel.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void removeShutdownListener(ShutdownListener listener) {
    throw new UnsupportedOperationException("This method is not currently supported as it is not used by current API in testing");

}
 
Example #15
Source File: TestConnection.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void addShutdownListener(ShutdownListener listener) {
    throw new UnsupportedOperationException("This method is not currently supported as it is not used by current API in testing");
}
 
Example #16
Source File: TestConnection.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void removeShutdownListener(ShutdownListener listener) {
    throw new UnsupportedOperationException("This method is not currently supported as it is not used by current API in testing");
}
 
Example #17
Source File: MockChannel.java    From rabbitmq-mock with Apache License 2.0 4 votes vote down vote up
@Override
public void addShutdownListener(ShutdownListener listener) {
    // do nothing
}
 
Example #18
Source File: MockConnection.java    From rabbitmq-mock with Apache License 2.0 4 votes vote down vote up
@Override
public void removeShutdownListener(ShutdownListener listener) {
    // do nothing
}
 
Example #19
Source File: MockConnection.java    From rabbitmq-mock with Apache License 2.0 4 votes vote down vote up
@Override
public void addShutdownListener(ShutdownListener listener) {
    // do nothing
}
 
Example #20
Source File: RabbitMQProducerAndConsumerConstructorInterceptorTest.java    From skywalking with Apache License 2.0 2 votes vote down vote up
@Override
public void addShutdownListener(ShutdownListener shutdownListener) {

}
 
Example #21
Source File: RabbitMQProducerAndConsumerConstructorInterceptorTest.java    From skywalking with Apache License 2.0 2 votes vote down vote up
@Override
public void removeShutdownListener(ShutdownListener shutdownListener) {

}