You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by LongkerDandy <lo...@gmail.com> on 2011/03/25 12:33:30 UTC

Eventadmin and producer consumer pattern

Hi
One of my event handler fetch info from internet and tends to block,
And this makes it timeout since pending event keep coming.

I wondered if event admin service can be used as producer/consumer pattern.
Or I have to implement the pattern myself, by using the event handler as a
producer.

Thanks
LongkerDandy

Re: Eventadmin and producer consumer pattern

Posted by Carsten Ziegeler <cz...@apache.org>.
Per-Erik Svensson  wrote
> Hi,
> 
> Maybe java.util.concurrent.BlockingQueue can help out if you need to
> implement a producer-consumer. There are unbounded queues
> (LinkedBlockingQueue) so you should be able to just put the information on
> the queue (unbounded shouldn't block on put operations) and process it
> elsewhere (in an Executor for example).
> 
This is what we're doing - an event handler just puts incoming events
into the queue - and therefore returns quickly.

And a background task is processing the items in the queue.

Regards
Carsten
-- 
Carsten Ziegeler
cziegeler@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Eventadmin and producer consumer pattern

Posted by Per-Erik Svensson <pe...@gmail.com>.
Hi,

Maybe java.util.concurrent.BlockingQueue can help out if you need to
implement a producer-consumer. There are unbounded queues
(LinkedBlockingQueue) so you should be able to just put the information on
the queue (unbounded shouldn't block on put operations) and process it
elsewhere (in an Executor for example).

Regards,
Per-Erik Svensson

On Wed, Mar 30, 2011 at 8:52 AM, Peter Kriens <pe...@aqute.biz>wrote:

> What do you think? :-)
>
> There is often a confusion about OSGi specs. Unlike many other specs, OSGi
> specs are not made to make your life easier, they're made to enable
> collaboration. Simplicity is very much in the eye of the beholder and is
> thus better left up to libraries that service a certain constituency. That
> said, we obviously try to make the specs as easy as possible to use but not
> at the cost of making them more complex to implement.
>
> Kind regards,
>
>        Peter Kriens
>
>
> You get the event but the contract is that you return quickly. So just run
> the body in an Executor.
>
>
>
> On 25 mrt 2011, at 12:33, LongkerDandy wrote:
>
> > Hi
> > One of my event handler fetch info from internet and tends to block,
> > And this makes it timeout since pending event keep coming.
> >
> > I wondered if event admin service can be used as producer/consumer
> pattern.
> > Or I have to implement the pattern myself, by using the event handler as
> a
> > producer.
> >
> > Thanks
> > LongkerDandy
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Eventadmin and producer consumer pattern

Posted by Peter Kriens <pe...@aqute.biz>.
What do you think? :-)

There is often a confusion about OSGi specs. Unlike many other specs, OSGi specs are not made to make your life easier, they're made to enable collaboration. Simplicity is very much in the eye of the beholder and is thus better left up to libraries that service a certain constituency. That said, we obviously try to make the specs as easy as possible to use but not at the cost of making them more complex to implement.

Kind regards,

	Peter Kriens


You get the event but the contract is that you return quickly. So just run the body in an Executor.



On 25 mrt 2011, at 12:33, LongkerDandy wrote:

> Hi
> One of my event handler fetch info from internet and tends to block,
> And this makes it timeout since pending event keep coming.
> 
> I wondered if event admin service can be used as producer/consumer pattern.
> Or I have to implement the pattern myself, by using the event handler as a
> producer.
> 
> Thanks
> LongkerDandy


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org