1. I am trying to use rabbitmq in our project..the listener part is not working… the only code that I have is the @rabbitistener annotation and cachingconnectionfactory which is passing the rabbitmq server details.. This works fine in a standalone springboot application but the same code is not working in my actual project which is a spring application only(deployed using war files)..
    The problem is I do not see any relevant logs…It is not attempting to connect to my rabbitmq server at all.. any hints as to why this may be happening would be really appreciated..
    P.S: Our current project is using IBM MQ and I have not disabled those libraries and beans..could it be affecting how rabbitmq listener is operating?

  2. It is a very good tutorial. Thanks!
    One question though. I want to publish a message(send an object) only when I update my DB. I don’t want to send it every 3 seconds, @scheduled (fixedDelay=3000L).
    Can you give me a hint how to do this?

  3. Excellent post, thank you very much!!!!

  4. Nice article. Can we use this code for sending and receiving text messages?

    1. Author

      Thanks. Yes you can, but I’d stick to a JSON structure anyways. You can always wrap those text messages in a minimal JSON structure so you can extend it in future if you need it.

  5. Hi, I don’t want to use the @scheduled (fixedDelay=3000L) to send the messages every 3 seconds, I want to send the message exactly once. Can you suggest the changes I would need to make?

    1. Author

      It depends on the trigger you want to use to send that message. If you want to start the app, send a message and wait for it to be delivered to shut it down, you could use a CountDownLatch object. You can also expose a REST API and then trigger that message whenever you call it… Feel free to further detail what you want to do on the GitHub repository, maybe I or someone else can help.

  6. How can I get dynamic queue names here?

    1. Author

      I don’t know if I got exactly what you meant here. I used annotations in this guide to set up queues and exchanges but you can always create queues programmatically with Java, and that way you’d get dynamic queues.

  7. Very interesting article. I have done it before but with Spring Cloud Stream (using Spring Boot and RabbitMQ). Do you know what are the advantages of one approach over the other?

    1. Author

      Thanks! Spring Cloud Stream is an abstraction, implementing the pub-sub pattern in a generic way so you can pick the binder later without (in theory) changing much of your code: say RabbitMQ or Kafka. It might be interesting for example for people who are familiar with Spring Integration since it has native integration with it. As an abstraction though, it has also the inconvenient that if you want to use specific features, you have to write vendor-specific code.

  8. Thanks, but whenever I start Spring application, it logs that application started twice. Do you have any idea why this is happening?

    1. Author

      Could you report an issue in the Github repo attaching the stack trace? I can have a look at it.

      1. I have asked this question here: https://stackoverflow.com/q/47344882/8955751.
        You can find details there.
        I am not getting any stacktrace, since application is running correctly.
        Only my concern is, why spring application is logging that it started twice.

  9. Thanks, can u do Event Sourcing with RabbitMq

  10. Nice post! It helps us a lot with migration of our rabbits to spring boot

  11. Thank you very much for the article ! It was really helpful.

  12. Hi MOISÉS, You saved my day! Wonderful post…

  13. Thanks for this article, I’m relatively new to spring and I found it very useful. Good luck with your book 🙂

    1. Author

      Thanks for your feedback! I’ll try to cover this and some other topics on my book so feel free to show your interest on Leanpub if you want to get a good discount!


This site uses Akismet to reduce spam. Learn how your comment data is processed.