You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by shin938 <sh...@gmail.com> on 2013/07/30 07:57:58 UTC

how to consume messages by timestamp

I have a simple route spring DSL ,activemq queue. I want to consume messages
that are 2 minutes old and more. what would be my best approach?



--
View this message in context: http://camel.465427.n5.nabble.com/how-to-consume-messages-by-timestamp-tp5736463.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: how to consume messages by timestamp

Posted by shin938 <sh...@gmail.com>.
Thank you all for the answers,
eventually I implemented Raul's suggestion,
my producer is a camel route and I set the TTL on the URI:

        <route id="conversionLogRequestRoute">
            <from uri="direct:conversionLogRequest" />
            <log message="Sending conversion log request to ActiveMQ" />
            <to
uri="activemq:Log.conversionLogRequestQueue?timeToLive=120000" />
        </route>

and I configured an individual DLQ for  Log.conversionLogRequestQueue.

the Delay and Schedule Message Delivery sounds cleaner , I wonder if I can
set the scheduler properties on the URI too, I will test that tomorrow. 



--
View this message in context: http://camel.465427.n5.nabble.com/how-to-consume-messages-by-timestamp-tp5736463p5736603.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: how to consume messages by timestamp

Posted by Raul Kripalani <ra...@evosent.com>.
Agree.

=== Method 2: Camel Aggregation EIP with unique ID correlation expression +
completionTimeout + persistent aggregation repository ===

Use an Aggregate EIP with a correlation expression that picks a unique ID
(e.g. exchangeId), such that aggregation buckets are always of size 1 each
containing one message. With a completionTimeout of 2 minutes, messages
will leave the aggregator once their lifetime reaches 2 minutes (or a bit
later, factoring in the timeout checker interval, etc.).

Make sure you use a Recoverable Aggregation Strategy such as LevelDB, JPA,
SQL, etc. so that no inflight exchanges will be lost in case of a disaster
or scheduled maintenance.

=== Method 3: Use the Scheduling support in ActiveMQ ===

See http://activemq.apache.org/delay-and-schedule-message-delivery.html.

Regards,

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Tue, Jul 30, 2013 at 9:39 PM, Christian Posta
<ch...@gmail.com>wrote:

> I like Raul's suggestion. It keeps the burden on the broker and the clients
> can be thin and simple.
>
> On the other hand, you could do this on the client side with an aggregator.
> Just consume messages from a queue as quickly as they come in, and let the
> aggregator hold on to them for 2 mins and then release them.
>
>
> On Tue, Jul 30, 2013 at 12:59 PM, Raul Kripalani <ra...@evosent.com> wrote:
>
> > I'll explain a possible solution briefly.
> >
> > === Leverage JMS expiration and ActiveMQ individual Dead Letter Queue ===
> >
> > Make your producers send messages with a JMS Time to Live of 2 minutes.
> If
> > you can't change your producers, implement an AMQ Broker Plugin that will
> > set the expiration inside the broker as soon as the message arrives.
> >
> > Set a destinationPolicy for the queue of interest with a custom, and use
> > AMQ's individualDeadLetterStrategy [1] so that expired messages go to a
> > dedicated queue whose name equals the name of the original destination,
> > preceded by the "ActiveMQ.DLQ.Queue." prefix.
> >
> > Build your Camel route to consume from the DLQ instead of from the
> original
> > queue. Your route will only consume messages that are 2 minutes old, or
> > older.
> >
> > Does this help?
> >
> > Regards,
> >
> > *Raúl Kripalani*
> > Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
> > Integration specialist
> > http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
> > http://blog.raulkr.net | twitter: @raulvk
> >
> > On Tue, Jul 30, 2013 at 6:57 AM, shin938 <sh...@gmail.com> wrote:
> >
> > > I have a simple route spring DSL ,activemq queue. I want to consume
> > > messages
> > > that are 2 minutes old and more. what would be my best approach?
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://camel.465427.n5.nabble.com/how-to-consume-messages-by-timestamp-tp5736463.html
> > > Sent from the Camel - Users mailing list archive at Nabble.com.
> > >
> >
>
>
>
> --
> *Christian Posta*
> http://www.christianposta.com/blog
> twitter: @christianposta
>

Re: how to consume messages by timestamp

Posted by Christian Posta <ch...@gmail.com>.
I like Raul's suggestion. It keeps the burden on the broker and the clients
can be thin and simple.

On the other hand, you could do this on the client side with an aggregator.
Just consume messages from a queue as quickly as they come in, and let the
aggregator hold on to them for 2 mins and then release them.


On Tue, Jul 30, 2013 at 12:59 PM, Raul Kripalani <ra...@evosent.com> wrote:

> I'll explain a possible solution briefly.
>
> === Leverage JMS expiration and ActiveMQ individual Dead Letter Queue ===
>
> Make your producers send messages with a JMS Time to Live of 2 minutes. If
> you can't change your producers, implement an AMQ Broker Plugin that will
> set the expiration inside the broker as soon as the message arrives.
>
> Set a destinationPolicy for the queue of interest with a custom, and use
> AMQ's individualDeadLetterStrategy [1] so that expired messages go to a
> dedicated queue whose name equals the name of the original destination,
> preceded by the "ActiveMQ.DLQ.Queue." prefix.
>
> Build your Camel route to consume from the DLQ instead of from the original
> queue. Your route will only consume messages that are 2 minutes old, or
> older.
>
> Does this help?
>
> Regards,
>
> *Raúl Kripalani*
> Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
> Integration specialist
> http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
> http://blog.raulkr.net | twitter: @raulvk
>
> On Tue, Jul 30, 2013 at 6:57 AM, shin938 <sh...@gmail.com> wrote:
>
> > I have a simple route spring DSL ,activemq queue. I want to consume
> > messages
> > that are 2 minutes old and more. what would be my best approach?
> >
> >
> >
> > --
> > View this message in context:
> >
> http://camel.465427.n5.nabble.com/how-to-consume-messages-by-timestamp-tp5736463.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Re: how to consume messages by timestamp

Posted by Raul Kripalani <ra...@evosent.com>.
I'll explain a possible solution briefly.

=== Leverage JMS expiration and ActiveMQ individual Dead Letter Queue ===

Make your producers send messages with a JMS Time to Live of 2 minutes. If
you can't change your producers, implement an AMQ Broker Plugin that will
set the expiration inside the broker as soon as the message arrives.

Set a destinationPolicy for the queue of interest with a custom, and use
AMQ's individualDeadLetterStrategy [1] so that expired messages go to a
dedicated queue whose name equals the name of the original destination,
preceded by the "ActiveMQ.DLQ.Queue." prefix.

Build your Camel route to consume from the DLQ instead of from the original
queue. Your route will only consume messages that are 2 minutes old, or
older.

Does this help?

Regards,

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Tue, Jul 30, 2013 at 6:57 AM, shin938 <sh...@gmail.com> wrote:

> I have a simple route spring DSL ,activemq queue. I want to consume
> messages
> that are 2 minutes old and more. what would be my best approach?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/how-to-consume-messages-by-timestamp-tp5736463.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: how to consume messages by timestamp

Posted by Christian Müller <ch...@gmail.com>.
I think there is a simpler solution. Use the Apache ActiveMQ schedule
delivery option [1].

[1] http://activemq.apache.org/delay-and-schedule-message-delivery.html

Best,
Christian
-----------------

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Tue, Jul 30, 2013 at 7:57 AM, shin938 <sh...@gmail.com> wrote:

> I have a simple route spring DSL ,activemq queue. I want to consume
> messages
> that are 2 minutes old and more. what would be my best approach?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/how-to-consume-messages-by-timestamp-tp5736463.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>