Skip to content

Instantly share code, notes, and snippets.

@acogoluegnes
Last active April 10, 2018 12:14
Show Gist options
  • Save acogoluegnes/efb087b75d9d2a710d0f9076f10e6b23 to your computer and use it in GitHub Desktop.
Save acogoluegnes/efb087b75d9d2a710d0f9076f10e6b23 to your computer and use it in GitHub Desktop.
MeterRegistry jmxRegistry = new JmxMeterRegistry(JmxConfig.DEFAULT, Clock.SYSTEM);
ConnectionFactory connectionFactory = new ConnectionFactory();
MicrometerMetricsCollector metricsCollector = new MicrometerMetricsCollector(
jmxRegistry, "rabbitmq.client"
);
connectionFactory.setMetricsCollector(metricsCollector);
Connection connection = connectionFactory.newConnection();
Channel channel = connection.createChannel();
String queue = channel.queueDeclare().getQueue();
channel.basicConsume(queue, true, (ctag, msg) -> { }, (ctag) -> { });
executor.submit(() -> {
Random random = new Random();
while (true) {
Thread.sleep(random.nextInt(100));
channel.basicPublish("", queue, null, "".getBytes());
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment