本文整理了Java中com.rabbitmq.client.Connection.isOpen()
方法的一些代码示例,展示了Connection.isOpen()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Connection.isOpen()
方法的具体详情如下:
包路径:com.rabbitmq.client.Connection
类名称:Connection
方法名:isOpen
暂无
代码示例来源:origin: apache/nifi
/**
* Validates that {@link Connection} is not null and open.
*
* @param connection instance of {@link Connection}
*/
private void validateConnection(Connection connection) {
if (connection == null) {
throw new IllegalArgumentException("'connection' must not be null!");
}
if (!connection.isOpen()) {
throw new IllegalStateException("'connection' must be open!");
}
}
}
代码示例来源:origin: Graylog2/graylog2-server
public boolean isConnected() {
return connection != null
&& connection.isOpen()
&& channel != null
&& channel.isOpen();
}
代码示例来源: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: yacy/yacy_grid_mcp
private void init() throws IOException {
ConnectionFactory factory = new ConnectionFactory();
factory.setAutomaticRecoveryEnabled(true);
factory.setHost(this.server);
if (this.port > 0) factory.setPort(this.port);
if (this.username != null && this.username.length() > 0) factory.setUsername(this.username);
if (this.password != null && this.password.length() > 0) factory.setPassword(this.password);
try {
this.connection = factory.newConnection();
//Map<String, Object> map = this.connection.getServerProperties();
if (!this.connection.isOpen()) throw new IOException("no connection");
this.channel = connection.createChannel();
if (!this.channel.isOpen()) throw new IOException("no channel");
this.queues = new ConcurrentHashMap<>();
} catch (TimeoutException e) {
throw new IOException(e.getMessage());
}
}
代码示例来源:origin: kodokojo/kodokojo
public boolean isConnected() {
synchronized (monitor) {
return connection != null && connection.isOpen();
}
}
代码示例来源:origin: org.apache.airavata/airavata-messaging-core
public boolean isOpen(){
if(connection!=null){
return connection.isOpen();
}
return false;
}
代码示例来源:origin: vert-x3/vertx-rabbitmq-client
@Override
public boolean isConnected() {
boolean connected = false;
if (connection != null) {
if (connection.isOpen()) {
connected = true;
}
}
return connected;
}
代码示例来源: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
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);
代码示例来源:origin: org.graylog2/graylog2-radio
public boolean isConnected() {
return connection != null
&& connection.isOpen()
&& channel != null
&& channel.isOpen();
}
代码示例来源:origin: org.graylog2/graylog2-server
public boolean isConnected() {
return connection != null
&& connection.isOpen()
&& channel != null
&& channel.isOpen();
}
代码示例来源:origin: de.unibonn.iai.eis/luzzu-io
public static void close() {
if(connection.isOpen()) {
try {
connection.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: NationalSecurityAgency/lemongrenade
public static void closeConnection(Connection connection) throws Exception {
try {
if(connection != null && connection.isOpen()) {
log.info("Closing RabbitMQ connection.");
connection.close();
}
}
catch(com.rabbitmq.client.AlreadyClosedException e) {
log.info("RabbitMQ connection already closed.");
}
}
代码示例来源:origin: org.graylog2/graylog2-inputs
public boolean isConnected() {
return connection != null
&& connection.isOpen()
&& channel != null
&& channel.isOpen();
}
代码示例来源:origin: meltwater/rxrabbit
private synchronized Connection getOrCreateConnection(ChannelType connectionType) throws IOException {
if (conToChannel.containsKey(connectionType)) {
if (conToChannel.get(connectionType).connection.isOpen()) {
return conToChannel.get(connectionType).connection;
}else{
//TODO not covered in tests
conToChannel.remove(connectionType);
}
}
return createConnection(connectionType);
}
代码示例来源:origin: de.unibonn.iai.eis/luzzu-io
public TriplePublisher() {
if(connection == null || channel == null || !connection.isOpen() || !channel.isOpen()) {
connect();
}
}
代码示例来源:origin: io.github.luzzu/luzzu-io
public TriplePublisher() {
if(connection == null || channel == null || !connection.isOpen() || !channel.isOpen()) {
connect();
}
}
代码示例来源:origin: de.unibonn.iai.eis/luzzu-io
public void close() {
try {
if(channel.isOpen()) {
channel.close();
}
if(connection.isOpen()) {
connection.close();
}
} catch (IOException e) {
logger.warn("Error closing channel or connection to MQ service", e);
}
}
代码示例来源:origin: io.github.luzzu/luzzu-io
public void close() {
try {
if(channel.isOpen()) {
channel.close();
}
if(connection.isOpen()) {
connection.close();
}
} catch (IOException | TimeoutException e) {
logger.warn("Error closing channel or connection to MQ service", e);
}
}
代码示例来源:origin: org.apache.james/apache-james-backends-rabbitmq
private Boolean isConnected() throws IOException, TimeoutException {
try (Connection connection = rabbitMQ.connectionFactory().newConnection()) {
return connection.isOpen();
}
}
内容来源于网络,如有侵权,请联系作者删除!