热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

com.rabbitmq.client.Connection.close()方法的使用及代码示例

本文整理了Java中com.rabbitmq.client.Connection.close()方法的一些代码示例,展示了Connection.close()的具体用法。这些代码示例主要来源于Gith

本文整理了Java中com.rabbitmq.client.Connection.close()方法的一些代码示例,展示了Connection.close()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Connection.close()方法的具体详情如下:
包路径:com.rabbitmq.client.Connection
类名称:Connection
方法名:close

Connection.close介绍

暂无

代码示例

代码示例来源:origin: apache/flink

@Override
public void close() throws Exception {
super.close();
try {
if (connection != null) {
connection.close();
}
} catch (IOException e) {
throw new RuntimeException("Error while closing RMQ connection with " + queueName
+ " at " + rmqConnectionConfig.getHost(), e);
}
}

代码示例来源:origin: apache/incubator-druid

@Override
public void close() throws IOException
{
log.info("Closing connection to RabbitMQ");
channel.close();
connection.close();
}
};

代码示例来源:origin: apache/flink

@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);
}
}

代码示例来源:origin: Graylog2/graylog2-server

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();
}
}

代码示例来源:origin: apache/nifi

@Override
public void close() throws IOException {
IOException ioe = null;
try {
worker.close();
} catch (final IOException e) {
ioe = e;
} catch (final TimeoutException e) {
ioe = new IOException(e);
}
try {
connection.close();
} catch (final IOException e) {
if (ioe == null) {
ioe = e;
} else {
ioe.addSuppressed(e);
}
}
if (ioe != null) {
throw ioe;
}
}

代码示例来源:origin: yacy/yacy_grid_mcp

@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;
}

代码示例来源:origin: vector4wang/spring-boot-quick

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();
}
}
}

代码示例来源:origin: io.dropwizard.metrics/metrics-graphite

@Override
public void close() throws IOException {
if (connection != null) {
connection.close();
}
}

代码示例来源:origin: org.smartdeveloperhub.curator/sdh-curator-connector

private void closeConnectionQuietly() {
if(this.connection!=null) {
try {
this.connection.close();
} catch (final Exception e) {
LOGGER.trace("Could not close connection gracefully",e);
}
this.cOnnection=null;
}
}

代码示例来源:origin: spring-projects/spring-integration

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);
}

代码示例来源:origin: spring-projects/spring-integration

ccf.destroy();
verify(channel, times(2)).close();
verify(connection).close(30000);

代码示例来源:origin: addthis/hydra

@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();
}
}

代码示例来源:origin: spring-projects/spring-amqp

@Override
public void close() {
try {
this.explicitlyClosed = true;
// let the physical close time out if necessary
this.delegate.close(this.closeTimeout);
}
catch (IOException e) {
throw RabbitExceptionTranslator.convertRabbitAccessException(e);
}
}

代码示例来源:origin: org.graylog2/gelfj

public void close() {
shutdown = true;
try {
channel.close();
} catch (Exception e) {
}
try {
connection.close();
} catch (Exception e) {
}
}
}

代码示例来源:origin: org.geoserver.community/gs-notification-common

public void close() throws Exception {
if (this.channel != null) {
this.channel.close();
}
if (this.conn != null) {
this.conn.close();
}
}

代码示例来源:origin: de.unibonn.iai.eis/luzzu-io

public static void close() {
if(connection.isOpen()) {
try {
connection.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

代码示例来源:origin: io.druid.extensions/druid-rabbitmq

@Override
public void close() throws IOException
{
log.info("Closing connection to RabbitMQ");
channel.close();
connection.close();
}
};

代码示例来源:origin: uk.gov.dstl.baleen/baleen-rabbitmq

@Override
protected void doDestroy() {
getMonitor().debug("Disconnecting from RabbitMQ");
try {
connection.close();
} catch (final Exception e) {
getMonitor().error("Could not close connection to RabbitMQ", e);
}
}
}

代码示例来源:origin: spring-projects/spring-amqp

@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();
}

代码示例来源:origin: spring-projects/spring-amqp

@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();
}

推荐阅读
author-avatar
宝宝2502932575
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有