Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Message from discussion Threading Policies
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Stefan Weber  
View profile  
 More options Nov 12 2009, 7:58 am
From: Stefan Weber <stefan.we...@gmail.com>
Date: Thu, 12 Nov 2009 13:58:13 +0100
Local: Thurs, Nov 12 2009 7:58 am
Subject: Re: Threading Policies

On Thu, Nov 12, 2009 at 9:32 AM, Sergio Bossa <sergio.bo...@gmail.com>wrote:

I know, I know, that's why I was recently considering to add to

> Actorom a bunch of commonly used handler implementation, such as
> "BalancingActor", "OffloadingActor" and so on ... do you think it
> could be a worthy addition?

Yes, I think this would be great. In case I'm really running into problems
with the sequantial execution of handlers, I'll try to implement something
in this direction and keep you updated of course.

Another idea I had: for my use case it would be nice to have more
flexibility regarding the selection of the handler method on the actor.
Currently, there is always the CoreHandler used internally but it would be
nice to plug in custom logic there.

For example, it would be very useful to have something along these lines:

class MyHandler {

@OnMessage(type = Message.class)
void handleFooMessage(Message msg) {...} // handles messages of type foo

@OnMessage(type = Message.class)
void handleBarMessage(Message msg) {...} // handles messages of type bar

}

The current implementation of course does not know which handler to call
here, so I am using more specific types in the @OnMessage annotation.
However, since I get a generic Message from the 3rd party app, I had to plug
in a factory that creates a more specific Message from the generic Message
before calling the send method on the actor (but in many cases, I don't need
this more specific Message later on).

so I would need to inject a CoreHandler when spawning the new actors (e.g.
something called MyCoreHandler that extends CoreHandler and overrides
handleOnMessage). I could then analyze the method name with reflection,
compare it with the message type of the currently processed message and then
dispatch based on this.

Could I make myself clear? :) What do you think? Does this make sense?

Best,

Stefan

> > Actually, I had to ideas how to implement it:
> > [CUT]
> > I prefer solution 2 because it is simpler.

> Agree: and #2 actually does what you describe in #1 under the hood, so
> don't reinvent the wheel :)

> > The only small doubt I have is
> > that I have to create a new Runnable for every message. I don't have
> enough
> > experience to guess how expensive this will be in practice but I assume
> it
> > will be easy to spot in case it really becomes a bottleneck. What do you
> > think?

> Absolutely agree: I don't think creating Runnable objects would be a
> problem and just in case you may want to tune your garbage collection
> to accommodate the large number of short-lived objects (by tuning the
> eden space) ... anyways, go with it and keep me posted.

> Cheers,

> Sergio B.

> --
> Sergio Bossa
> Software Passionate and Open Source Enthusiast.
> URL: http://www.linkedin.com/in/sergiob


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.