Hi!

Welcome to the ActiveMQ community! :-)

Here's some interesting reading:
http://www.activemq.org/site/how-does-a-queue-compare-to-a-topic.html
http://www.activemq.org/site/how-do-durable-queues-and-topics-work.html

In a nutshell I guess, when you use queues, each message is stored in the queue until a consumer consumes them (each message will be consumed by only one consumer), while for topics, each message will be send to all consumers currently subscribed to the topic. If there is no consumers, the message is discarded. If you want to receive messages using topics while your consumer is offline, you could use durable subscriptions, but the condition is that you must first subscribe to the topic before going offline. (i.e. tell the broker that you are interested in the topic's messages.)

Another workaround is to use the recovery policies of ActiveMQ. This allows you to somewhat go back in time and receive some of the messages you've missed. You must specify a retroactive consumer to use this:
http://www.activemq.org/site/retroactive-consumer.html
http://www.activemq.org/site/subscription-recovery-policy.html

Hope these helps!

Regards,
Adrian Co

wizard wrote:
Hi, I'm new to amq, so I have a basic question, I guess.

I've created a queue, with a producer and a consumer, and I was able to send
messages, and keep them in queue.

Now I've changed to using a topic, and I still send and receive messages,
but the behaviour has changed: when I produce a message and the consumer is
running, it instantly gets the message. But when I produce a message and the
consumer isn't running, I seem to lose the message, because when I connect
the consumer, it doesn't read any message at all, and my queue size is
always 0.

Is this how topics are supposed to work? What is wrong?

Reply via email to