activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Tully <gary.tu...@gmail.com>
Subject Re: Keeping the messages in a queue or topic during a day
Date Tue, 07 Jun 2011 09:57:48 GMT
have a peek at the tests:

http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/retroactive/

you need to configure a recovery policy on the destinations via the
broker xml configuration. the default policy is to not hold on to any
messages.

On 6 June 2011 11:53, serious <serious.seb@orange.fr> wrote:
> @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.
>



-- 
http://fusesource.com
http://blog.garytully.com

Mime
View raw message