@Override public void close() throws TimeoutException, IOException { if (closed) { return; } if (logger.isDebugEnabled()) { logger.debug("Closing AMQP channel for " + this.channel.getConnection().toString()); } this.channel.close(); closed = true; }
@Override public void close() throws IOException { log.info("Closing connection to RabbitMQ"); channel.close(); connection.close(); } };
@Override public void close() { Exception t = null; try { if (channel != null) { channel.close(); } } catch (IOException | TimeoutException e) { t = e; } try { if (connection != null) { connection.close(); } } catch (IOException e) { if (t != null) { LOG.warn("Both channel and connection closing failed. Logging channel exception and failing with connection exception", t); } t = e; } if (t != null) { throw new RuntimeException("Error while closing RMQ connection with " + queueName + " at " + rmqConnectionConfig.getHost(), t); } }
public void stop() throws IOException { if (channel != null && channel.isOpen()) { try { channel.close(); } catch (TimeoutException e) { LOG.error("Timeout when closing AMQP channel", e); channel.abort(); } } if (connection != null && connection.isOpen()) { connection.close(); } }
public void destruct() { try { eventChan.close(); } catch (IOException e) { throw new CloudRuntimeException(e); } }
@Override public void close() { this.queues.clear(); try { this.channel.close(); } catch (IOException | TimeoutException e) {} try { this.connection.close(); } catch (IOException e) {} this.queues = null; }
void destruct() throws IOException { for (Channel chan : pool) { try { chan.close(); } catch (IOException e) { chan.abort(); } } } }
public void destruct() { try { nrouteChan.close(); } catch (IOException e) { throw new CloudRuntimeException(e); } }
public static void main(String[] args) { try { ConnectionFactory factory = new ConnectionFactory(); factory.setUsername("guest"); factory.setPassword("guest"); factory.setHost("60.205.191.82"); factory.setPort(5672); Connection conn = factory.newConnection(); Channel channel = conn.createChannel(); // channel.qu channel.queueDeclare("hello", false, false, false, null); String message = "Hello World!"; channel.basicPublish("", "hello", null, message.getBytes()); System.out.println(" [x] Sent '" + message + "'"); channel.close(); conn.close(); } catch (IOException e) { e.printStackTrace(); } catch (TimeoutException e) { e.printStackTrace(); } } }
@Override public void destroyObject(Channel t) throws Exception { try { t.close(); } catch (Exception e) { //no-op } }
private void testNackOrRequeue(boolean requeue) throws IOException, TimeoutException { Channel channel = mock(Channel.class); willReturn(true).given(channel).isOpen(); Envelope envelope = new Envelope(123L, false, "ex", "rk"); BasicProperties props = new BasicProperties.Builder().build(); GetResponse getResponse = new GetResponse(envelope, props, "bar".getBytes(), 0); willReturn(getResponse).given(channel).basicGet("foo", false); Connection connection = mock(Connection.class); willReturn(true).given(connection).isOpen(); willReturn(channel).given(connection).createChannel(); ConnectionFactory connectionFactory = mock(ConnectionFactory.class); willReturn(connection).given(connectionFactory).newConnection((ExecutorService) isNull(), anyString()); CachingConnectionFactory ccf = new CachingConnectionFactory(connectionFactory); AmqpMessageSource source = new AmqpMessageSource(ccf, "foo"); Message<?> received = source.receive(); verify(connection).createChannel(); StaticMessageHeaderAccessor.getAcknowledgmentCallback(received) .acknowledge(requeue ? Status.REQUEUE : Status.REJECT); verify(channel).basicReject(123L, requeue); verify(connection).createChannel(); ccf.destroy(); verify(channel).close(); verify(connection).close(30000); }
@Override public void close() throws IOException { if (channel != null) { try { channel.close(); } catch (TimeoutException e) { log.warn("[rabbit.producer] error timeout", e); } } if (connection != null) { connection.close(); } }
@Override public void close(int closeCode, String closeMessage) throws IOException, TimeoutException { this.delegate.close(closeCode, closeMessage); if (this.delegate instanceof AutorecoveringChannel) { ClosingRecoveryListener.removeChannel((AutorecoveringChannel) this.delegate); } }
public void close() { shutdown = true; try { channel.close(); } catch (Exception e) { } try { connection.close(); } catch (Exception e) { } } }
public void close() throws Exception { if (this.channel != null) { this.channel.close(); } if (this.conn != null) { this.conn.close(); } }
private void closeQuietly(final Channel channel) { if(channel.isOpen()) { try { channel.close(); } catch (final Exception e) { LOGGER.trace("Could not close channel gracefully",e); } } }
public void close() { logger.info("Closing subscription. {}", identificationInformation()); coordinator.close(); try { consumerChannel.close(); } catch (IOException | TimeoutException e) { logger.error(e.getMessage(), e); } logger.info("Subscription is closed. {}", identificationInformation()); }
@Test public void test(ConnectionFactory connectionFactory) throws Exception { Connection conn = connectionFactory.newConnection(); Channel channel = conn.createChannel(); DeclareOk declareOk = channel.queueDeclarePassive("rabbitAvailableTests.queue"); assertEquals(0, declareOk.getConsumerCount()); channel.close(); conn.close(); }
@Test public void test(ConnectionFactory cf) throws Exception { assertSame(cf, this.connectionFactory); Connection conn = this.connectionFactory.newConnection(); Channel channel = conn.createChannel(); DeclareOk declareOk = channel.queueDeclarePassive("rabbitAvailableTests.queue"); assertEquals(0, declareOk.getConsumerCount()); channel.close(); conn.close(); }