Search code examples
javajmsqpid

Qpid asynchronous messaging with Java


I am new to Qpid and JMS and I'm trying to make a very simple Java application using Qpid Java broker.

I am implementing this example that simply sends and receives a predefined message.
http://qpid.apache.org/releases/qpid-0.24/qpid-jms/examples/Hello.java.html

I divided the application in 2 parts, consumer and producer.

If I start the consumer part of the example first, and then I start the producer one, everything is ok and the message is consumed.

But if I start the producer first and then the consumer, the message is lost.

In other words, how can I store the messages sent by a producer in order to retrieve them later with the consumer application?

Thanks in advance!


Solution

  • You are emitting/listening to/from an EXCHANGE, to get the behaviour you're describing you should create a QUEUE and use it as your message destination for the emitter.

    If you are using the Apache QPID broker Java implementation, you can create a new QUEUE following this steps at the broker web administration site:

    enter image description here enter image description here enter image description here

    At you code side you should change the EXCHANGE name you were using to the new QUEUE's name.