On Wed, Nov 11, 2009 at 3:53 PM, Stefan Weber <
stefan...@gmail.com> wrote:
> I'm working on an application that is supposed to serve as an adapter
> to a 3rd party product. The communication to the latter happens with
> ASCII messages over TCP/IP and I found that dispatching the incoming
> messages to their handlers seems like a good case to try Actorom. It
> actually works very good, I hardly had to restructure the application
> and could get rid of a lot of code. So thanks for that :)
Great to know about your use case, thanks for sharing :)
> However, since the OSMessageDispatcher ensures that messages handled
> by the same actor run sequentially I have some worries when the
> handler takes longer (I need to parse potentially big ASCII message,
> for example) than the inter arrival time of its messages.
> If I understand the actors model correctly, this is to ensure that the
> actor does not need to worry about synchronization. However, if the
> handler is state less, it seems like it should be no problem for this
> actor to accept messages concurrently.
>
> What is your thought on this? Do you discourage this upfront or do you
> think it could make sense?
I didn't implement "concurrent" actors because of two main reasons:
1) They break the principles of the actors model itself.
2) They could be misused, leading people to use actors in wrong ways.
That said, I'm not saying to be completely *against* such a use case:
just let's discuss it and see if there's some better way of doing the
same thing.
> I was thinking to implement a MessageDispatcher myself that does the
> same thing as the OSMessageDispatcher but allowing concurrent handling
> on the same actor if it has the @ThreadSafe annotation.
Another way to offload actors for stateless tasks could be to use an
external thread pool and schedule those tasks on it: by doing so,
actors would be used only to represent the messaging abstraction,
while the actual computation would be executed on another thread
(launched by the actor who received the related message).
What do you think?
Just let me know if you need more details about this solution.
Cheers,
Sergio B.
--
Sergio Bossa
Software Passionate and Open Source Enthusiast.
URL:
http://www.linkedin.com/in/sergiob