Thanks for that, and I realised after I sent the message that multiple
Tasks cannot listen on a single mailbox. So does anyone have any
suggestions as to how I would make my Task multithreaded, so that I
can process multiple messages off the Mailbox in parallel, rather than
serial?
Was your last sentence a proposed direction.
I think I managed to get further. Not sure if it was what you were talking about. What I did is I moved the logic out of KilimWaiter into a single use actor. I create this actor and start it and stick the message in the inbox. So now the "Task2" can take as long as it wants.
I just need to solve this same problem for fork join pattern probably the same way.
Sent from my Galaxy S2
Not sure my description was very clear.
Basically KilimWaiter looks like this now:
while(true) {
Message msg = inbox.get();
KilimWorkerTask task = new KilimWorkerTask();
task.start();
task.getInbox().put(msg);
}
The worker task is single use, so no while loop.
Any issues other than lots of one use objects?
Already using kilim heavily do not want to change it out if I can help it. Besides I love how well actors and mailboxes map to my domain I just have a couple of long running tasks that I cannot split into smaller pieces do need to parallel them.
Sent from my Galaxy S2
Actually no since kilim is scheduler is limited to a certain number of threads. All i am doing is adding some additional tasks to be executed, but still on the same number of threads.
My solution is certainly not as drastic or bad as you indicate. I actually suspect its reasonable, looking for a kilim user to comment.
Also these longer running process are sometimes 10s of seconds but often sub second. And they need to be executed within a chain of actors as i am implementing a workflow solution and some actors can take longer so really looking to get them working with kilim.
I realise i may be stretching the usecase but kilim is a great fit otherwise.
I have a producer who produces multiple 'request' messages and posts
them onto a processor mailbox (in my example this is the KilimWaiter
actor), I want the KilimWaiter to be able
to process request messages in parallel.
Currently what happens is the kilimwaiter (processor actor) processes
the messages serially which is not what I was expecting.
I am hoping there is an obvious pattern i am missing? I don't want to
have to try and round robbin to multiple processor actors so that I
can artificially implement parallism for this task.
Its potentially a very large graph of actors to implement a workflow. Each actor represents a node each outgoing mail box represents a edge to another node. Most nodes will have at least 2 or more out going edges.
I will certainly look at your suggestions.
I already was exploring the temporary consumer idea.
I think it would already be throttled by the number of kilim threads available would it not?
also I do care what task picks up the message. I actually wanted to be able to have a task be able to be processing multiple messages at once.
Anyway your last suggestion is close to what I was thinking and I will also evaluate an alternative inter thread messaging pattern as well.
Appreciate everyone's responses so far. Very helpful
Sent from my Galaxy S2
Probably not 1000s though maybe 100 or so on average