Adding an event queue?

15 views
Skip to first unread message

Sean Corfield

unread,
Oct 1, 2009, 1:38:23 AM10/1/09
to edmund-coldfusion
Currently, listeners in Edmund are either synchronous or asynchronous.
A synchronous listener is executed "immediately" when an event is
dispatched (well, as soon as Edmund hits it in the list of subscribers
for that event) and control returns to Edmund when the listener is
finished. An asynchronous listener is also executed "immediately" but
control returns to Edmund "immediately" because the listener is
executed in a thread.

I'm looking at a use case for Edmund that would be most easily solved
by adding a third type of listener: a queue.

When an event is dispatched, Edmund would go through the list of
subscribers and for a queued listener, it would simply add the event
to an internal queue and continue through the list. A separate thread
would be spawned when Edmund was initialized that would repeatedly
check the queue and actually invoke the listeners. The listeners would
effectively be synchronous and be executed in the order that events
were dispatched but they would all execute in a separate thread to the
main program.

I'm actually looking at a few implementation options for the queue:
in-memory (in the same instance as Edmund), in-database (which could,
in theory, allow for execution of listeners across multiple machines)
and perhaps others that folks can imagine up :)

First off, do folks think this would be useful?

Second, what would folks like to see in this sort of feature?
--
Sean A Corfield -- (904) 302-SEAN
Railo Technologies US -- http://getrailo.com/
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

Adam Haskell

unread,
Oct 1, 2009, 7:36:04 AM10/1/09
to edmund-c...@googlegroups.com
I guess I'll have to think about this more but right now I am failing to get the benefit of the queue over asynchronous. Is it a matter of having synchronous events across multiple requests?

Adam

Gavin Baumanis

unread,
Oct 1, 2009, 6:45:16 PM10/1/09
to edmund-c...@googlegroups.com
Hi Adam,

I could of course be completely wrong - and am more than happy to be corrected too.

But surely the ability to have a queue of events enable you to order the events that will fire.
So you can create fairly discreet events, and then fire them in any order you required - where that order might be slightly different in different parts of the application - although over the whole - possibly the same?

Kind of like a fuseaction for events?

As for wat would I like to see???
(Using my fuseaction analogy)
I'm thinking, timeouts .
Timeouts for the whole fuseaction.
Timeouts for individual events in the event queue

And appropriate handling for what to do when a timeout is reached.

With a bit more thought (as long as my assumptions is correct - with respect to what you're initially thinking about Sean) I'm sure I can come up with some other things to do.


Gavin.

As always Please contact me if I can be of any further assistance.

Gavin "Beau" Baumanis
Senior Application Developer
PalCare P/L

657 Nicholson Street
Carlton North
Victoria, Australia, 3054


Sean Corfield

unread,
Oct 4, 2009, 12:46:45 PM10/4/09
to edmund-c...@googlegroups.com
On Thu, Oct 1, 2009 at 4:36 AM, Adam Haskell <a.ha...@gmail.com> wrote:
> I guess I'll have to think about this more but right now I am failing to get
> the benefit of the queue over asynchronous. Is it a matter of having
> synchronous events across multiple requests?

Well, if you had a listener that has to essentially single thread a
process (it operates on a shared resource and must lock) then you're
better off queuing events for it than trying to fire them all off
asynchronously, especially if it's long-running.

There's also the possibility of making the queue cluster-aware so that
any server in a cluster could handle a given event but you'd be
guaranteed each event is only handled once. I've had scenarios in the
past where I have a cluster where every member of the cluster is
capable of handling each event but then you have to ensure whichever
one gets to the event first is the only one to handle the event (this
is a problem that comes up with scheduled tasks running in a cluster,
for example).

JMS enables both of these of course but I'm wondering if there's a way
to do it effectively within Edmund without requiring some external
agent like JMS (although of course a queue architecture that
transparently allows for multiple implementations - including JMS -
would be my ideal solution).

John Allen

unread,
Oct 6, 2009, 2:53:56 PM10/6/09
to edmund-c...@googlegroups.com
I like the idea of the que and think that a threaded que could be useful for a couple of use cases.

Would the firing order of the listeners in the que depend on how edmond was initialized?

I also like the idea about using the db for multiple machines.

Sean Corfield

unread,
Oct 6, 2009, 6:01:08 PM10/6/09
to edmund-c...@googlegroups.com
On Tue, Oct 6, 2009 at 11:53 AM, John Allen <johnf...@gmail.com> wrote:
> Would the firing order of the listeners in the que depend on how edmond was
> initialized?

That would depend on whether I added a single queue for all events or
for each event or whether each listener had its own queue. I'm open to
suggestions :)

John Allen

unread,
Oct 7, 2009, 11:54:50 AM10/7/09
to edmund-c...@googlegroups.com
"Each listener would have its own queue". That makes scene.
Reply all
Reply to author
Forward
0 new messages