Example usage for com.rabbitmq.client Connection getServerProperties

List of usage examples for com.rabbitmq.client Connection getServerProperties

Introduction

In this page you can find the example usage for com.rabbitmq.client Connection getServerProperties.

Prototype

Map<String, Object> getServerProperties();

Source Link

Document

Retrieve the server properties.

Usage

From source file:com.springsource.insight.plugin.rabbitmqClient.AbstractRabbitMQCollectionAspect.java

License:Apache License

protected void applyConnectionData(Operation op, Connection conn) {
    String connectionUrl = null;// w  w w. j  a  v  a  2 s.  co m

    if (conn instanceof AMQConnection) {
        connectionUrl = conn.toString();
    } else {
        InetAddress address = conn.getAddress();
        int port = conn.getPort();

        StringBuilder sb = new StringBuilder("amqp://");
        sb.append(address.getHostAddress()).append(":").append(port);

        connectionUrl = sb.toString();
    }

    op.put("host", conn.getAddress().getHostAddress());
    op.put("port", conn.getPort());
    op.put("connectionUrl", connectionUrl);

    //try to extract server version
    String version = getVersion(conn.getServerProperties());
    op.put("serverVersion", version);

    //try to extract client version
    version = getVersion(conn.getClientProperties());
    op.put("clientVersion", version);
}

From source file:org.springframework.boot.actuate.amqp.RabbitHealthIndicatorTests.java

License:Apache License

@Test
public void healthWhenConnectionSucceedsShouldReturnUpWithVersion() {
    Connection connection = mock(Connection.class);
    given(this.channel.getConnection()).willReturn(connection);
    given(connection.getServerProperties()).willReturn(Collections.singletonMap("version", "123"));
    Health health = new RabbitHealthIndicator(this.rabbitTemplate).health();
    assertThat(health.getStatus()).isEqualTo(Status.UP);
    assertThat(health.getDetails()).containsEntry("version", "123");
}