0
votes

On client machine, I am using spring-rabbit-1.6.7.RELEASE.jar and spring-amqp-1.6.7.RELEASE.jar to perform operations on RabbitMQ.

Now, need is to monitor the metrics like # of open channels, # of rejected messages etc from given client machine to RabbitMQ server.

www.rabbitmq.com/monitoring.html mentions that some client libraries and frameworks provide means of registering metrics collectors or collect metrics out of the box. RabbitMQ Java client and Spring AMQP are two examples.

Please suggest how I can use Spring AMQP to collect metrics with respect to given client machine to RabbitMQ server.

Please note I am using org.springframework.amqp.rabbit.connection.CachingConnectionFactory. But it doesn't have any method to set metric collector..

We are using xml with following tags to define connection factory, queue, binding etc.

Rabbit:Queues , Rabbit:queue-arguments , • Rabbit:DIRECTExchange , Rabbit:TOPICExchange, Rabbit:binding , Rabbit:Admin [[[ ConnectionFactory]]]

e.g.

<bean id="connectionFactory"
    class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
    <constructor-arg value="#{messagingProperties['mq.hostname']}" />
    <property name="virtualHost" value="#{messagingProperties['mq.virtual-host']}" />
    <property name="username" value="#{messagingProperties['mq.username']}" />
    <property name="password" value="#{messagingProperties['mq.password']}" />
    <property name="channelCacheSize" value="25" />
</bean>
1

1 Answers

0
votes

1.6.7 is extremely old; you should upgrade to at least 1.7.14; the current version is 2.1.8.

You can set the metricsCollector on the underlying rabbit connection factory.

connectionFactory.getRabbitConnectionFactory().setMetricsCollector(...);

Or use the RabbitConnectionFactoryBean to create the underlying connection factory, and then inject it into the CachingConnectionFactory.

<bean id="rcf" class= "...RabbitConnectionFactoryBean">
    ... set all the properties here
</bean>


<bean id="connectionFactory"
class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
    <constructor-arg ref="rcf" />
    <property name="channelCacheSize" value="25" />
</bean>