Examples of the Java API

33 views
Skip to first unread message

Khaled Essghaier

unread,
Mar 22, 2011, 3:49:10 PM3/22/11
to akka...@googlegroups.com
Hi hAkkers,

I am trying to use Akka with play framework but i couldn't figure out a proper way to use actors + dispatchers with the Java API.
So my use case goes like this a request is handled by a controller (that's the play part) then what i want to do is to dispatch this call to a bench of Akka actors.

Thanks,

--Khaled
________________________________________________________

http://about.me/khaled

√iktor Ҝlang

unread,
Mar 22, 2011, 4:12:39 PM3/22/11
to akka...@googlegroups.com
Hi Khaled,

Do you have a question?

Did you try to look at http://doc.akka.io?

Cheers,

--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.



--
Viktor Klang,
Code Connoisseur
Work:   Scalable Solutions
Code:   github.com/viktorklang
Follow: twitter.com/viktorklang
Read:   klangism.tumblr.com

Khaled Essghaier

unread,
Apr 5, 2011, 5:39:59 PM4/5/11
to akka...@googlegroups.com, √iktor Ҝlang
Hi Victor,

Yes i was stuck on getting started on setting a dispatcher with a supervisor using the Java API and i am looking for some Java samples.
But Anyway i managed to create a supervisor with a workstealingdispatcher and a bench of actors now i got another problem actually
the message i send to my actors don't get through and i am always getting an exception :

Exception in thread "I/O-LOOP" java.lang.IllegalArgumentException
    at java.util.concurrent.ThreadPoolExecutor.<init>(ThreadPoolExecutor.java:589)
    at java.util.concurrent.ThreadPoolExecutor.<init>(ThreadPoolExecutor.java:514)
    at akka.dispatch.ThreadPoolConfig.createExecutorService(ThreadPoolBuilder.scala:70)
    at akka.dispatch.ThreadPoolConfig$$anonfun$createLazyExecutorService$1.apply(ThreadPoolBuilder.scala:61)
    at akka.dispatch.ThreadPoolConfig$$anonfun$createLazyExecutorService$1.apply(ThreadPoolBuilder.scala:61)
    at akka.dispatch.LazyExecutorServiceWrapper.createExecutor(ThreadPoolBuilder.scala:263)
    at akka.dispatch.LazyExecutorService$class.executor(ThreadPoolBuilder.scala:258)
    at akka.dispatch.LazyExecutorServiceWrapper.executor(ThreadPoolBuilder.scala:262)
    at akka.dispatch.ExecutorServiceDelegate$class.execute(ThreadPoolBuilder.scala:225)
    at akka.dispatch.LazyExecutorServiceWrapper.execute(ThreadPoolBuilder.scala:262)
    at akka.dispatch.ExecutorBasedEventDrivenWorkStealingDispatcher.dispatch(ExecutorBasedEventDrivenWorkStealingDispatcher.scala:66)
    at akka.dispatch.MessageDispatcher$class.dispatchMessage(MessageHandling.scala:68)
    at akka.dispatch.ExecutorBasedEventDrivenWorkStealingDispatcher.dispatchMessage(ExecutorBasedEventDrivenWorkStealingDispatcher.scala:36)
    at akka.actor.LocalActorRef.postMessageToMailboxAndCreateFutureResultWithTimeout(ActorRef.scala:819)
    at akka.actor.ScalaActorRef$class.$bang$bang$bang(ActorRef.scala:1342)
    at akka.actor.LocalActorRef.$bang$bang$bang(ActorRef.scala:552)
    at akka.actor.ActorRef$class.sendRequestReplyFuture(ActorRef.scala:341)
    at akka.actor.LocalActorRef.sendRequestReplyFuture(ActorRef.scala:552)
    at akka.actor.ActorRef$class.sendRequestReplyFuture(ActorRef.scala:321)
    at akka.actor.LocalActorRef.sendRequestReplyFuture(ActorRef.scala:552)
    at org.usichallenge.quizzor.handlers.UserCreationRequestHandler.post(UserCreationRequestHandler.java:36)
    at org.deftserver.web.http.HttpRequestDispatcher.dispatch(HttpRequestDispatcher.java:21)
    at org.deftserver.web.http.HttpProtocol.handleRead(HttpProtocol.java:62)
    at org.deftserver.io.IOLoop.start(IOLoop.java:69)
    at org.usichallenge.quizzor.Quizzor.start(Quizzor.java:55)
    at org.usichallenge.quizzor.Quizzor.main(Quizzor.java:39)

i am trying to use requestReplyFuture something like this :

Future<?> result = Actors.registry().actorsFor(UsersActor.class)[0].sendRequestReplyFuture(request.getBody());

Any idea how to fix this ?

Thx for your help

--Khaled
________________________________________________________
http://about.me/khaled



2011/3/22 √iktor Ҝlang <viktor...@gmail.com>

Jonas Bonér

unread,
Apr 6, 2011, 1:58:10 AM4/6/11
to akka...@googlegroups.com, Khaled Essghaier, √iktor Ҝlang
Do yo have a reproducible test? 

2011/4/5 Khaled Essghaier <thoughts.l...@gmail.com>



--
Jonas Bonér

Specialist at Large
work: http://scalablesolutions.se
code: http://akka.io
blog: http://jonasboner.com
twtr: @jboner



Khaled Essghaier

unread,
Apr 6, 2011, 10:24:27 AM4/6/11
to Jonas Bonér, akka...@googlegroups.com, √iktor Ҝlang
ohh i see that some of the discussion between me and Viktor didn't go into the main thread.
the problem was that i had maximumPoolSize < corePoolSize which throws the exception ! but it's fixed now :)
my other question is :

in the class ThreadPoolConfigDispatcherBuilder the method 
withNewBoundedThreadPoolWithLinkedBlockingQueueWithUnboundedCapacity(int i)

takes an int as a parameter ? what is it ? i couldn't find any doc on it ?

Viktor told me that this should be the capacity, but i don't quite understand the capacity of what ? the queue ? wasn't it supposed to have unbounded capacity?

thx

--Khaled
________________________________________________________
http://about.me/khaled



2011/4/6 Jonas Bonér <jo...@jonasboner.com>

√iktor Ҡlang

unread,
Apr 6, 2011, 10:44:31 AM4/6/11
to Khaled Essghaier, Jonas Bonér, akka...@googlegroups.com


2011/4/6 Khaled Essghaier <thoughts.l...@gmail.com>

ohh i see that some of the discussion between me and Viktor didn't go into the main thread.
the problem was that i had maximumPoolSize < corePoolSize which throws the exception ! but it's fixed now :)
my other question is :

in the class ThreadPoolConfigDispatcherBuilder the method 
withNewBoundedThreadPoolWithLinkedBlockingQueueWithUnboundedCapacity(int i)

takes an int as a parameter ? what is it ? i couldn't find any doc on it ?

Viktor told me that this should be the capacity, but i don't quite understand the capacity of what ? the queue ? wasn't it supposed to have unbounded capacity?

The thread pools execution queue. it adds 1 entry for each actor that currently has one or more messages in it's mailbox.
 



--
Viktor Klang,
Director of Research and Development

Khaled Essghaier

unread,
Apr 7, 2011, 3:58:37 PM4/7/11
to √iktor Ҡlang, Jonas Bonér, akka...@googlegroups.com
Thanks for your help !


2011/4/6 √iktor Ҡlang <viktor...@gmail.com>
Reply all
Reply to author
Forward
0 new messages