You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Bertrand Delacretaz <bd...@apache.org> on 2015/01/21 12:26:48 UTC

Re: Batched processing of OSGi events happening in the same short period

Hi,

On Wed, Jan 21, 2015 at 12:06 PM, Robert Munteanu <ro...@apache.org> wrote:
> ...What I'd like to do is batch and process events only after some quiet
> time ( 500 ms for instance ). For each event, I would place it in queue
> and wait for 500ms to see if another event comes in. If another event
> comes in, the timer is restarted. Once the timer is complete, I'd
> process all the events in one go....

Note that you'll need some additional logic to make sure you still
process events if they keep on coming without quiet time.

> ...I can implement this myself ( and have fun ), but I was wondering
> whether there are any building blocks in Sling that I can use for this....

I'm pretty sure I implemented something like this to process JCR
events in this way, but I cannot find it now :-/

We probably don't have something reusable, if you can create a
reusable EventClusteringQueue (?) that's useful. Maybe under
bundles/commons?

-Bertrand

Re: Batched processing of OSGi events happening in the same short period

Posted by Robert Munteanu <ro...@apache.org>.
On Wed, Jan 21, 2015 at 1:26 PM, Bertrand Delacretaz
<bd...@apache.org> wrote:
> Hi,
>
> On Wed, Jan 21, 2015 at 12:06 PM, Robert Munteanu <ro...@apache.org> wrote:
>> ...What I'd like to do is batch and process events only after some quiet
>> time ( 500 ms for instance ). For each event, I would place it in queue
>> and wait for 500ms to see if another event comes in. If another event
>> comes in, the timer is restarted. Once the timer is complete, I'd
>> process all the events in one go....
>
> Note that you'll need some additional logic to make sure you still
> process events if they keep on coming without quiet time.

Ack

>
>> ...I can implement this myself ( and have fun ), but I was wondering
>> whether there are any building blocks in Sling that I can use for this....
>
> I'm pretty sure I implemented something like this to process JCR
> events in this way, but I cannot find it now :-/
>
> We probably don't have something reusable, if you can create a
> reusable EventClusteringQueue (?) that's useful. Maybe under
> bundles/commons?

OK. I Intentionally simplified my scenario a bit - the batching should
be applied only for distinct parts of the content subtree, e.g.
/content/a and /content/b will not get batched together, but
/content/a and /content/a/1 OR /content/a/1 and /content/a/2 will. If
I can create something generic I'll submit back.

Thanks,

Robert