...
Code Block | ||||
---|---|---|---|---|
| ||||
package com.irdeto.keystone.service.notification; import com.rabbitmq.client.Channel; import com.rabbitmq.client.Connection; import com.rabbitmq.client.ConnectionFactory; import com.rabbitmq.client.DeliverCallback; public class TestConsumer { private final static String NOTIFICATION_QUEUE = "keystone_notifications"; public static void main(String[] argv) throws Exception { ConnectionFactory factory = new ConnectionFactory(); factory.setHost("localhost"); factory.setUsername("rabbit"); factory.setPassword("password"); Connection connection = factory.newConnection(); Channel channel = connection.createChannel(); channel.queueDeclare(NOTIFICATION_QUEUE,true,false, false, null); System.out.println(" [*] Waiting for messages. To exit press CTRL+C"); DeliverCallback deliverCallback = (consumerTag, delivery) -> { String message = new String(delivery.getBody(), "UTF-8"); System.out.println(" [x] Received '" + message + "'"); }; channel.basicConsume(NOTIFICATION_QUEUE, true, deliverCallback, consumerTag -> { }); } } |
Management API
You can install an optional management plugin for RabbitMQ. This will allow you to query RabbitMQ from CLI and REST.
CLI:
See https://www.rabbitmq.com/management-cli.html
REST:
https://pulse.mozilla.org/api/
References
Reference | URL |
---|---|
Tutorials | http://www.rabbitmq.com/getstarted.html |
Management CLI | https://www.rabbitmq.com/management-cli.html |
Rest Reference | https://pulse.mozilla.org/api/ |