Spring RabbitMQ java Hello World : Sender not sending any messages to the Queue

330 views
Skip to first unread message

Prasandeep Singh

unread,
Sep 9, 2017, 1:17:38 AM9/9/17
to rabbitmq-users
I followed all the instructions mentioned in the tutorial. I am able to run the code and Spring runs fine. But the sender does not sends any message to the queue. How do I send/recieve msgs from the queue? Is there a command/LOC that I am missing? 
no-output.png

Gary Russell

unread,
Sep 9, 2017, 10:20:31 AM9/9/17
to rabbitm...@googlegroups.com
I just built tutorial 1 per the instructions and had no problems.

Did you add @EnableScheduling to the RabbitAmqpTutorialsApplication as instructed?

@SpringBootApplication
@EnableScheduling
public class RabbitAmqpTutorialsApplication {

The sender uses Spring's scheduling mechanism...

 @Scheduled(fixedDelay = 1000, initialDelay = 500)


On Sat, Sep 9, 2017 at 1:17 AM, Prasandeep Singh <prasa...@gmail.com> wrote:
I followed all the instructions mentioned in the tutorial. I am able to run the code and Spring runs fine. But the sender does not sends any message to the queue. How do I send/recieve msgs from the queue? Is there a command/LOC that I am missing? 

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Prasandeep Singh

unread,
Sep 9, 2017, 10:45:43 AM9/9/17
to rabbitmq-users
Yes, I do have that annotation added. Should'nt there be a call to the sender/reciever from the run method here? 
The code output from me is just this console message for both sender and reciever: 
 @Override
 
public void run(String... arg0) throws Exception {
 
// TODO Auto-generated method stub
 
System.out.println("Ready ... running for "+ duration +" ms");
 
Thread.sleep(duration);
 ctx
.close();
 
}


On Saturday, 9 September 2017 10:20:31 UTC-4, Gary Russell wrote:
I just built tutorial 1 per the instructions and had no problems.

Did you add @EnableScheduling to the RabbitAmqpTutorialsApplication as instructed?

@SpringBootApplication
@EnableScheduling
public class RabbitAmqpTutorialsApplication {

The sender uses Spring's scheduling mechanism...

 @Scheduled(fixedDelay = 1000, initialDelay = 500)

On Sat, Sep 9, 2017 at 1:17 AM, Prasandeep Singh <prasa...@gmail.com> wrote:
I followed all the instructions mentioned in the tutorial. I am able to run the code and Spring runs fine. But the sender does not sends any message to the queue. How do I send/recieve msgs from the queue? Is there a command/LOC that I am missing? 

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.

Gary Russell

unread,
Sep 9, 2017, 11:23:49 AM9/9/17
to rabbitm...@googlegroups.com
No; as I said, it uses Spring's inbuilt scheduling mechanism to invoke the sender once per second, on a task scheduler thread.

Turn on DEBUG logging (in the yaml file).

If you still can't figure it out; post your project to github or similar and I'll see what you are missing.

To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.

Prasandeep Singh

unread,
Sep 9, 2017, 11:28:28 AM9/9/17
to rabbitmq-users
Its up and running now. I was creating a separate package for tut1 instead of putting it inside package org.springframework.amqp.tutorials.tut1;
Moving it to this highlighted package got everything working!

One issue though - If I already have a queue(queue name = "hello") implement in Python(say), I am not able to receive messages from the java receiver. This is the error I get : 

Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'hello' in vhost '/': received 'true' but current is 'false', class-id=50, method-id=10)


Gary Russell

unread,
Sep 9, 2017, 11:38:03 AM9/9/17
to rabbitm...@googlegroups.com
Yes, boot only looks for configuration files in the same package as the boot application, by default; you can configure the @SpringBootApplication to include other packages.

>inequivalent arg 'durable' for queue 'hello' in vhost '/': received 'true' but current is 'false', class-id=50, method-id=10)

The tutorial declares the queue as durable but your existing queue is not durable; you can't declare a queue with different properties.

For an existing queue, simply remove the Queue @Bean from the config file, so the app won't try to declare it; or use the constructor with more arguments to set equivalent values (durable=false, etc) to those that exist on the queue.




To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.

Prasandeep Singh

unread,
Sep 9, 2017, 11:58:05 AM9/9/17
to rabbitmq-users
Thanks! that helped alot! 
Reply all
Reply to author
Forward
0 new messages