I am working on a basic example and am not able to work it out.
I need to forward messages from one machine (Machine1) to another (Machine2) via a queue (TestQ). Producer is running on the Machine1 and a consumer on the Machine2.
My settings in the Machine1's rabbit broker config:
{rabbitmq_shovel, [ {shovels, [
{shovel_test, [
{sources, [{broker, "amqp://" }]},
{destinations, [{broker, "amqp://Machine2" }]},
{queue, <<"TestQ">>},
{ack_mode, on_confirm},
{reconnect_delay, 5}
]}
]} ]}
Machine2 has a default config and no shovel plugin enabled.
Producer's code running on the Machine1:
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
channel.queueDeclare("TestQ", true, false, false, null);
channel.basicPublish("", "TestQ", null, "Hello World!".getBytes());
Consumer's code running on the Machine2:
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
channel.queueDeclare("TestQ", true, false, false, null);
QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume("TestQ", true, consumer);
while (true) {
QueueingConsumer.Delivery delivery = consumer.nextDelivery();
String message = new String(delivery.getBody());
System.out.println(" [x] Received '" + message + "'");
}
Executing rabbitmqctl eval 'rabbit_shovel_status:status().' on the Machine1:
[{shovel_test,starting,{{2014,1,7},{9,47,38}}}]
...done.
Producer sends ok, but I never get a receive from the consumer on the Machine2.
Where is a problem? Something is missing in the conf of Machine1's broker, or Machine2's broker?
Thank you!
The status of your shovel should be
running, notstarting. If it stays in thestartingphase, that means it can't start up correctly (e.g. can't connect to the destination broker).One problem I spotted is that you used
brokerinstead ofbrokersfor specifying the list of sources. Try this: