Reading 'old' messages from ActiveMQ virtual topic from C# (.net Core) with Apache.NMS

597 Views Asked by At

How do I read messages on a virtual topic with Apache.NMS?

After creating the connection and session and consumer, I do: "consumer.Receive();".

Messages sent while that code is running are received, but any messages that were already on the topic before that, are not.

I tried adding "?consumer.retroactive=true" to the topic but that doesn't seem to do anything.

I've seen examples using durable subscribers, but when using a virtual topic I shouldn't have to do that.

1

There are 1 best solutions below

0
Kris Van Hulle On

Solved:

Problem was that I was reading from the wrong place: I was reading from a topic, while I should have been reading from a queue.

Virtual topics are topics, but you have to consume them from a consumer queue.

So, messages are pushed to "VirtualTopic.YourTopicName" and you should read from a QUEUE named "Consumer.YourConsumerName.VirtualTopic.YourTopicName". (Obviously this queue should exist before any messages are published.)

The reason that 'old' messages weren't read, is because they just weren't there.