Last active
April 10, 2018 12:15
-
-
Save acogoluegnes/fc2206cc22fdb3a7200a9bf070b5ac15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MeterRegistry jmxRegistry = new JmxMeterRegistry(JmxConfig.DEFAULT, Clock.SYSTEM); | |
// JVM and system metrics: | |
new ClassLoaderMetrics().bindTo(jmxRegistry); | |
new JvmMemoryMetrics().bindTo(jmxRegistry); | |
new JvmGcMetrics().bindTo(jmxRegistry); | |
new ProcessorMetrics().bindTo(jmxRegistry); | |
new JvmThreadMetrics().bindTo(jmxRegistry); | |
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