activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serious <>
Subject Re: Keeping the messages in a queue or topic during a day
Date Mon, 06 Jun 2011 10:53:16 GMT
@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

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

ConnectionFactory connectionFactory = new

var producerConnection = connectionFactory.CreateConnection();

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

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

var consumerConnection = connectionFactory.CreateConnection();

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

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

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

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

System.Console.Write("Press enter to exit...");

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 ?


View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message