@Gary : thanks for the pointer, this looks like the ideal solution.

But I can't make it work, here is some code that does not work as expected :
(Note : this is some C# using the NMS API but this is very close to
Java+JMS)

[code]// Generate a new unique topic name
string retroactiveTopicName = "testRetro_" + Guid.NewGuid() + ".topic";

ConnectionFactory connectionFactory = new
ConnectionFactory("tcp://localhost:61616");

var producerConnection = connectionFactory.CreateConnection();
producerConnection.Start();

var producerSession = (Session)producerConnection.CreateSession();

var producer = producerSession.CreateProducer();

var message = producer.CreateTextMessage("First message!");

// Send a first message
producer.Send(producerSession.GetTopic(retroactiveTopicName), message);

message = producer.CreateTextMessage("Second message!") as
ActiveMQTextMessage;

// Send a second message
producer.Send(producerSession.GetTopic(retroactiveTopicName), message);

var consumerConnection = connectionFactory.CreateConnection();
consumerConnection.Start();

var consumerSession = (Session)consumerConnection.CreateSession();

var consumer =
(MessageConsumer)consumerSession.CreateConsumer(consumerSession.GetTopic(retroactiveTopicName
+ "?consumer.retroactive=true"));
// Wait for incoming messages
consumer.Listener += incomingMessage =>
{
        Console.WriteLine("Consumer in : {0}!", (incomingMessage as
ITextMessage).Text);
};

message = producer.CreateTextMessage("Third message!");

// Send a third message
producer.Send(producerSession.GetTopic(retroactiveTopicName), message);

System.Console.Write("Press enter to exit...");
System.Console.ReadLine();[/code]

The producer sends three messages : two before the consumer is connected,
one after.
But the consumer only receives the third one, so the "retroactive" flag
seems to be completely ignored.

What am I doing wrong ?

Thanks.

--
View this message in context: 
http://activemq.2283324.n4.nabble.com/Keeping-the-messages-in-a-queue-or-topic-during-a-day-tp3561343p3576662.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to