Search in sources :

Example 1 with BlockedListener

use of com.rabbitmq.client.BlockedListener in project rabbitmq-java-client by rabbitmq.

the class BlockedConnection method connection.

private Connection connection(final CountDownLatch latch) throws IOException, TimeoutException {
    ConnectionFactory factory = TestUtils.connectionFactory();
    Connection connection = factory.newConnection();
    connection.addBlockedListener(new BlockedListener() {

        public void handleBlocked(String reason) throws IOException {
            try {
                unblock();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        public void handleUnblocked() throws IOException {
            latch.countDown();
        }
    });
    return connection;
}
Also used : ConnectionFactory(com.rabbitmq.client.ConnectionFactory) Connection(com.rabbitmq.client.Connection) BlockedListener(com.rabbitmq.client.BlockedListener) IOException(java.io.IOException)

Aggregations

BlockedListener (com.rabbitmq.client.BlockedListener)1 Connection (com.rabbitmq.client.Connection)1 ConnectionFactory (com.rabbitmq.client.ConnectionFactory)1 IOException (java.io.IOException)1