[akka-user] AKKA - JAVA

2018-02-13 Thread S SATHISH BABU
Hello, I am new to Akka. I want to learn to develop Distributed programs. I 
searched for tutorials but couldn't find anything proper. The Akka 
documentation is too dry and theoretical. Where can I find Akka 
implementation in Java tutorials?!

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Akka-Java Routing Issue

2017-05-03 Thread Guido Medina
I'm not sure if you can "forward" instead of "route" to a router, if not 
you could probably set the router sender to sender() and just reply to the 
sender from the processing actor,
that way you won't need to correlate, it should be do-able using existing 
sender() reply mechanism.

The trick would be to:

router.route(message,sender());

HTH,

Guido.

On Tuesday, April 25, 2017 at 9:33:40 AM UTC+1, Vishwa Bhat wrote:
>
> Nice, That's one solution but what if I have to do some processing on 
> 'MainActor' when I get response from child and then I have to send to 
> 'MyApp'?
>
> Regards,
> Vishwa
>
> On Tuesday, April 25, 2017 at 1:38:09 PM UTC+5:30, Arnout Engelen wrote:
>>
>> Hi Vishwa,
>>
>> You correctly noticed that, when handling the Integer message that was 
>> sent to the 'MainActor' by your child actor, 'sender()' will refer to that 
>> child actor.
>>
>> If you want the response to go to the 'original' sender ('MyApp'), one 
>> solution might be to use 'sender()' as the second parameter to 'route': 
>> this will tell the child to send its response directly to 'MyApp', 
>> effectively 'forwarding' the message.
>>
>>
>> Kind regards,
>>
>> Arnout
>>
>> On Tue, Apr 25, 2017 at 8:57 AM, Vishwa Bhat  
>> wrote:
>>
>>> I have the following issue in Akka-Java.
>>>
>>> I have one Parent Actor `MainActor.class` and this parent has 5 child 
>>> routes. Following is the hierarchy:
>>>
>>> *My App => Main Actor => [Child Route-1,Child-Route-2,..]*
>>>
>>> Simple Use case is String input is parsed to Integer as output: 
>>>
>>> *MyApp ===ask[string input]===> Main Actor ==route==> Child(parses to 
>>> Integer) === integer result===> Main Actor ===result==> MyApp*
>>>
>>> Here is the Main Actor snippet:
>>>
>>>
>>>  class MainActor extends UntypedActor{
>>> 
>>>Router router;
>>>{
>>>  // ...routes are configured here
>>>}
>>> 
>>>public void onReceive(Object message){
>>>  if(message instanceof String){
>>>  router.route(message,self()); // route it to child
>>>  }else if(message instanceof Integer){
>>> // received from child, 'tell' this result to actual 
>>> sender/parent i.e, MyApp
>>> sender().tell(message,self()); 
>>>  }else unhandled(message);
>>> }
>>>  }
>>>
>>> And Child Actor does nothing but String parsing to Integer and takes the 
>>> result and sends it back to it's sender by 
>>> `sender().tell(result,getContext().parent())`
>>>
>>> *Issue*
>>>
>>> MainActor is sending the Parsed integer result sent by child back to 
>>> child itself instead of `MyApp`. I also tried replacing `*sender()*` to 
>>> `*getContext().parent()*` in `MainActor` but still it did not work.
>>>
>>> -- 
>>> >> Read the docs: http://akka.io/docs/
>>> >> Check the FAQ: 
>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>> >> Search the archives: 
>>> https://groups.google.com/group/akka-user
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Akka User List" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to akka-user+...@googlegroups.com.
>>> To post to this group, send email to akka...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/akka-user.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> Arnout Engelen
>> *Senior Software Engineer*
>> E: arnout@lightbend.com
>> T: https://twitter.com/raboofje
>>
>>
>>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Akka-Java Routing Issue

2017-04-25 Thread Arnout Engelen
There's a number of possibilities: if the processing is stateless you could
use the 'ask' and 'pipe' patterns and 'map' (
http://doc.akka.io/docs/akka/current/java/futures.html#Use_with_Actors ).

Another approach might be to wrap the messages to and from the child actors
in an 'envelope' that also contains some kind of unique 'correlation id',
and in MainActor keep a Map from correlation id to original sender.


Arnout

On Tue, Apr 25, 2017 at 10:33 AM, Vishwa Bhat 
wrote:

> Nice, That's one solution but what if I have to do some processing on
> 'MainActor' when I get response from child and then I have to send to
> 'MyApp'?
>
> Regards,
> Vishwa
>
> On Tuesday, April 25, 2017 at 1:38:09 PM UTC+5:30, Arnout Engelen wrote:
>>
>> Hi Vishwa,
>>
>> You correctly noticed that, when handling the Integer message that was
>> sent to the 'MainActor' by your child actor, 'sender()' will refer to that
>> child actor.
>>
>> If you want the response to go to the 'original' sender ('MyApp'), one
>> solution might be to use 'sender()' as the second parameter to 'route':
>> this will tell the child to send its response directly to 'MyApp',
>> effectively 'forwarding' the message.
>>
>>
>> Kind regards,
>>
>> Arnout
>>
>> On Tue, Apr 25, 2017 at 8:57 AM, Vishwa Bhat 
>> wrote:
>>
>>> I have the following issue in Akka-Java.
>>>
>>> I have one Parent Actor `MainActor.class` and this parent has 5 child
>>> routes. Following is the hierarchy:
>>>
>>> *My App => Main Actor => [Child Route-1,Child-Route-2,..]*
>>>
>>> Simple Use case is String input is parsed to Integer as output:
>>>
>>> *MyApp ===ask[string input]===> Main Actor ==route==> Child(parses to
>>> Integer) === integer result===> Main Actor ===result==> MyApp*
>>>
>>> Here is the Main Actor snippet:
>>>
>>>
>>>  class MainActor extends UntypedActor{
>>>
>>>Router router;
>>>{
>>>  // ...routes are configured here
>>>}
>>>
>>>public void onReceive(Object message){
>>>  if(message instanceof String){
>>>  router.route(message,self()); // route it to child
>>>  }else if(message instanceof Integer){
>>> // received from child, 'tell' this result to actual
>>> sender/parent i.e, MyApp
>>> sender().tell(message,self());
>>>  }else unhandled(message);
>>> }
>>>  }
>>>
>>> And Child Actor does nothing but String parsing to Integer and takes the
>>> result and sends it back to it's sender by `sender().tell(result,getConte
>>> xt().parent())`
>>>
>>> *Issue*
>>>
>>> MainActor is sending the Parsed integer result sent by child back to
>>> child itself instead of `MyApp`. I also tried replacing `*sender()*` to
>>> `*getContext().parent()*` in `MainActor` but still it did not work.
>>>
>>> --
>>> >> Read the docs: http://akka.io/docs/
>>> >> Check the FAQ: http://doc.akka.io/docs/akka/c
>>> urrent/additional/faq.html
>>> >> Search the archives: https://groups.google.com/grou
>>> p/akka-user
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Akka User List" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to akka-user+...@googlegroups.com.
>>> To post to this group, send email to akka...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/akka-user.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Arnout Engelen
>> *Senior Software Engineer*
>> E: arnout@lightbend.com
>> T: https://twitter.com/raboofje
>>
>>
>> --
> >> Read the docs: http://akka.io/docs/
> >> Check the FAQ: http://doc.akka.io/docs/akka/
> current/additional/faq.html
> >> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Arnout Engelen
*Senior Software Engineer*
E: arnout.enge...@lightbend.com
T: https://twitter.com/raboofje

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more 

Re: [akka-user] Akka-Java Routing Issue

2017-04-25 Thread Vishwa Bhat
Nice, That's one solution but what if I have to do some processing on 
'MainActor' when I get response from child and then I have to send to 
'MyApp'?

Regards,
Vishwa

On Tuesday, April 25, 2017 at 1:38:09 PM UTC+5:30, Arnout Engelen wrote:
>
> Hi Vishwa,
>
> You correctly noticed that, when handling the Integer message that was 
> sent to the 'MainActor' by your child actor, 'sender()' will refer to that 
> child actor.
>
> If you want the response to go to the 'original' sender ('MyApp'), one 
> solution might be to use 'sender()' as the second parameter to 'route': 
> this will tell the child to send its response directly to 'MyApp', 
> effectively 'forwarding' the message.
>
>
> Kind regards,
>
> Arnout
>
> On Tue, Apr 25, 2017 at 8:57 AM, Vishwa Bhat  > wrote:
>
>> I have the following issue in Akka-Java.
>>
>> I have one Parent Actor `MainActor.class` and this parent has 5 child 
>> routes. Following is the hierarchy:
>>
>> *My App => Main Actor => [Child Route-1,Child-Route-2,..]*
>>
>> Simple Use case is String input is parsed to Integer as output: 
>>
>> *MyApp ===ask[string input]===> Main Actor ==route==> Child(parses to 
>> Integer) === integer result===> Main Actor ===result==> MyApp*
>>
>> Here is the Main Actor snippet:
>>
>>
>>  class MainActor extends UntypedActor{
>> 
>>Router router;
>>{
>>  // ...routes are configured here
>>}
>> 
>>public void onReceive(Object message){
>>  if(message instanceof String){
>>  router.route(message,self()); // route it to child
>>  }else if(message instanceof Integer){
>> // received from child, 'tell' this result to actual 
>> sender/parent i.e, MyApp
>> sender().tell(message,self()); 
>>  }else unhandled(message);
>> }
>>  }
>>
>> And Child Actor does nothing but String parsing to Integer and takes the 
>> result and sends it back to it's sender by 
>> `sender().tell(result,getContext().parent())`
>>
>> *Issue*
>>
>> MainActor is sending the Parsed integer result sent by child back to 
>> child itself instead of `MyApp`. I also tried replacing `*sender()*` to `
>> *getContext().parent()*` in `MainActor` but still it did not work.
>>
>> -- 
>> >> Read the docs: http://akka.io/docs/
>> >> Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >> Search the archives: https://groups.google.com/group/akka-user
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to akka-user+...@googlegroups.com .
>> To post to this group, send email to akka...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Arnout Engelen
> *Senior Software Engineer*
> E: arnout@lightbend.com 
> T: https://twitter.com/raboofje
>
>
>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Akka-Java Routing Issue

2017-04-25 Thread Arnout Engelen
Hi Vishwa,

You correctly noticed that, when handling the Integer message that was sent
to the 'MainActor' by your child actor, 'sender()' will refer to that child
actor.

If you want the response to go to the 'original' sender ('MyApp'), one
solution might be to use 'sender()' as the second parameter to 'route':
this will tell the child to send its response directly to 'MyApp',
effectively 'forwarding' the message.


Kind regards,

Arnout

On Tue, Apr 25, 2017 at 8:57 AM, Vishwa Bhat 
wrote:

> I have the following issue in Akka-Java.
>
> I have one Parent Actor `MainActor.class` and this parent has 5 child
> routes. Following is the hierarchy:
>
> *My App => Main Actor => [Child Route-1,Child-Route-2,..]*
>
> Simple Use case is String input is parsed to Integer as output:
>
> *MyApp ===ask[string input]===> Main Actor ==route==> Child(parses to
> Integer) === integer result===> Main Actor ===result==> MyApp*
>
> Here is the Main Actor snippet:
>
>
>  class MainActor extends UntypedActor{
>
>Router router;
>{
>  // ...routes are configured here
>}
>
>public void onReceive(Object message){
>  if(message instanceof String){
>  router.route(message,self()); // route it to child
>  }else if(message instanceof Integer){
> // received from child, 'tell' this result to actual
> sender/parent i.e, MyApp
> sender().tell(message,self());
>  }else unhandled(message);
> }
>  }
>
> And Child Actor does nothing but String parsing to Integer and takes the
> result and sends it back to it's sender by `sender().tell(result,
> getContext().parent())`
>
> *Issue*
>
> MainActor is sending the Parsed integer result sent by child back to child
> itself instead of `MyApp`. I also tried replacing `*sender()*` to `
> *getContext().parent()*` in `MainActor` but still it did not work.
>
> --
> >> Read the docs: http://akka.io/docs/
> >> Check the FAQ: http://doc.akka.io/docs/akka/
> current/additional/faq.html
> >> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Arnout Engelen
*Senior Software Engineer*
E: arnout.enge...@lightbend.com
T: https://twitter.com/raboofje

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Akka-Java Routing Issue

2017-04-25 Thread Vishwa Bhat
I have the following issue in Akka-Java.

I have one Parent Actor `MainActor.class` and this parent has 5 child 
routes. Following is the hierarchy:

*My App => Main Actor => [Child Route-1,Child-Route-2,..]*

Simple Use case is String input is parsed to Integer as output: 

*MyApp ===ask[string input]===> Main Actor ==route==> Child(parses to 
Integer) === integer result===> Main Actor ===result==> MyApp*

Here is the Main Actor snippet:


 class MainActor extends UntypedActor{

   Router router;
   {
 // ...routes are configured here
   }

   public void onReceive(Object message){
 if(message instanceof String){
 router.route(message,self()); // route it to child
 }else if(message instanceof Integer){
// received from child, 'tell' this result to actual 
sender/parent i.e, MyApp
sender().tell(message,self()); 
 }else unhandled(message);
}
 }

And Child Actor does nothing but String parsing to Integer and takes the 
result and sends it back to it's sender by 
`sender().tell(result,getContext().parent())`

*Issue*

MainActor is sending the Parsed integer result sent by child back to child 
itself instead of `MyApp`. I also tried replacing `*sender()*` to `
*getContext().parent()*` in `MainActor` but still it did not work.

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] [Akka/Java] Scala exception when updating maven dependencies

2017-04-04 Thread Mark McShane
I have tried that and it doesn't work, still getting the exception. 
Thanks for the reply though, here's how I edited the pom.xml:




On Tuesday, 4 April 2017 06:08:59 UTC+1, Patrik Nordwall wrote:
>
> You must use the same version for all Akka artifacts, e.g. 2.12_2.4.17 for 
> everything. Cluster-metrics exists for that version.
>
> Akka 2.4.x is released for Scala 2.11 and 2.12 but you have to pick one 
> and don't mix.
>
> /Patrik
> mån 3 apr. 2017 kl. 20:33 skrev Mark McShane  >:
>
>> I'm working on a project making use of various Akka modules in Java 
>> (akka-actor, akka-remote etc.). These modules were loaded in as 
>> dependencies through maven, each version being around Akka 2.10:3.9. I left 
>> the dependencies at these versions as I figured "If it ain't broke then 
>> don't fix it", and things are working as expected.
>>
>> I wanted to test some features from akka-cluster-metrics, but I'm have 
>> problems when I include the dependency in my pom.xml. I suspect the issue 
>> is some sort of problem with scala major versions. *I'm hoping that 
>> perhaps someone could give me some advice on how to fix my problem.*
>>
>> I'm getting the same exception (listed a bit below) regardless of the 
>> versions of each dependency. The format for the jars (see 
>> https://mvnrepository.com/) seems to be *akka-_2.> version>:*. At first I thought if I updated the old akka 
>> 2.10 jars to being akka 2.12, the problem would be resolved, but I still 
>> get the exception.
>>
>> The exception occurs consistently at the first place akka/scala is used 
>> in my application, this works fine prior to meddling with dependencies.
>> final ActorSystem system = ActorSystem.create("QuadraticSystem",
>> ConfigFactory.parseString("akka.remote.netty.tcp {" +
>> "\nhostname =\"" + analysisInfo[0] + "\"" +
>> "\nport=" + analysisInfo[1] +
>> "\n}").
>> withFallback(ConfigFactory.load("application.conf")));
>>
>> A cleaned up form of the exception:
>> Exception in thread "main" java.lang.VerifyError: Uninitialized object 
>> exists on backward branch 209
>> Exception Details:
>>   Location:
>> 
>> scala/collection/immutable/HashMap$HashTrieMap.split()Lscala/collection/immutable/Seq;
>>  
>> @249: goto
>>   Reason:
>> Error exists in the bytecode
>>   Bytecode:
>> 0x000: 2ab6 0057 04a0 001e b200 afb2 00b4 04bd
>> 0x010: 0002 5903 2a53 c000 b6b6 00ba b600 bec0
>> ...
>> Stackmap Table:
>> same_frame(@35)
>>
>> full_frame(@141,{Object[#2],Integer,Integer,Integer,Integer,Integer,Object[#105]},{})
>> append_frame(@151,Object[#125],Object[#125])
>> at 
>> scala.collection.immutable.HashMap$.scala$collection$immutable$HashMap$$makeHashTrieMap(HashMap.scala:179)
>> at scala.collection.immutable.HashMap$HashMap1.updated0(HashMap.scala:211)
>> ...
>> at akka.actor.ActorSystem$Settings.(ActorSystem.scala:328)
>> at akka.actor.ActorSystemImpl.(ActorSystem.scala:683)
>> at akka.actor.ActorSystem$.apply(ActorSystem.scala:245)
>> at akka.actor.ActorSystem$.apply(ActorSystem.scala:288)
>> at akka.actor.ActorSystem$.apply(ActorSystem.scala:263)
>> at akka.actor.ActorSystem$.create(ActorSystem.scala:191)
>> at akka.actor.ActorSystem.create(ActorSystem.scala)
>> at uk.ac.qub.ccrcb.bioinf.ssc.CMDLauncher.main(CMDLauncher.java:38) > above code segment>
>>
>> For the record, my existing (working) pom.xml contains the following 
>> relevant dependencies:
>> akka-actor, akka-remote (both 2.10_2.3.9), typesafe config 1.2.1, 
>> scala-library 2.10.4.
>>
>> When I tried to update each dependency to 2.12, each is at:
>> akka-actor, akka-remote, akka-cluster-metrics (all at 2.12_2.4.17), 
>> typesafe config 1.3.1, scala-library 2.12.1.
>>
>> The earliest jar I can get cluster-metrics for is 2.11 (major version of 
>> scala still incompatible, afaik). Any configuration of versions I have 
>> tried result in this same exception. For reference, 
>> I'm using a Macbook Pro running macOs Sierra 10.12.3. My java version is 
>> the 'latest' I could get from the oracle site (although I'm confused as 
>> there seems to be inconsistency between the versions of java listed, I can 
>> only find one jdk myself).
>>
>>
>> 
>>
>>
>> -- 
>> >> Read the docs: http://akka.io/docs/
>> >> Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >> Search the archives: https://groups.google.com/group/akka-user
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send 

Re: [akka-user] [Akka/Java] Scala exception when updating maven dependencies

2017-04-03 Thread Patrik Nordwall
You must use the same version for all Akka artifacts, e.g. 2.12_2.4.17 for
everything. Cluster-metrics exists for that version.

Akka 2.4.x is released for Scala 2.11 and 2.12 but you have to pick one and
don't mix.

/Patrik
mån 3 apr. 2017 kl. 20:33 skrev Mark McShane :

> I'm working on a project making use of various Akka modules in Java
> (akka-actor, akka-remote etc.). These modules were loaded in as
> dependencies through maven, each version being around Akka 2.10:3.9. I left
> the dependencies at these versions as I figured "If it ain't broke then
> don't fix it", and things are working as expected.
>
> I wanted to test some features from akka-cluster-metrics, but I'm have
> problems when I include the dependency in my pom.xml. I suspect the issue
> is some sort of problem with scala major versions. *I'm hoping that
> perhaps someone could give me some advice on how to fix my problem.*
>
> I'm getting the same exception (listed a bit below) regardless of the
> versions of each dependency. The format for the jars (see
> https://mvnrepository.com/) seems to be *akka-_2. version>:*. At first I thought if I updated the old akka
> 2.10 jars to being akka 2.12, the problem would be resolved, but I still
> get the exception.
>
> The exception occurs consistently at the first place akka/scala is used in
> my application, this works fine prior to meddling with dependencies.
> final ActorSystem system = ActorSystem.create("QuadraticSystem",
> ConfigFactory.parseString("akka.remote.netty.tcp {" +
> "\nhostname =\"" + analysisInfo[0] + "\"" +
> "\nport=" + analysisInfo[1] +
> "\n}").
> withFallback(ConfigFactory.load("application.conf")));
>
> A cleaned up form of the exception:
> Exception in thread "main" java.lang.VerifyError: Uninitialized object
> exists on backward branch 209
> Exception Details:
>   Location:
>
> scala/collection/immutable/HashMap$HashTrieMap.split()Lscala/collection/immutable/Seq;
> @249: goto
>   Reason:
> Error exists in the bytecode
>   Bytecode:
> 0x000: 2ab6 0057 04a0 001e b200 afb2 00b4 04bd
> 0x010: 0002 5903 2a53 c000 b6b6 00ba b600 bec0
> ...
> Stackmap Table:
> same_frame(@35)
>
> full_frame(@141,{Object[#2],Integer,Integer,Integer,Integer,Integer,Object[#105]},{})
> append_frame(@151,Object[#125],Object[#125])
> at
> scala.collection.immutable.HashMap$.scala$collection$immutable$HashMap$$makeHashTrieMap(HashMap.scala:179)
> at scala.collection.immutable.HashMap$HashMap1.updated0(HashMap.scala:211)
> ...
> at akka.actor.ActorSystem$Settings.(ActorSystem.scala:328)
> at akka.actor.ActorSystemImpl.(ActorSystem.scala:683)
> at akka.actor.ActorSystem$.apply(ActorSystem.scala:245)
> at akka.actor.ActorSystem$.apply(ActorSystem.scala:288)
> at akka.actor.ActorSystem$.apply(ActorSystem.scala:263)
> at akka.actor.ActorSystem$.create(ActorSystem.scala:191)
> at akka.actor.ActorSystem.create(ActorSystem.scala)
> at uk.ac.qub.ccrcb.bioinf.ssc.CMDLauncher.main(CMDLauncher.java:38)  above code segment>
>
> For the record, my existing (working) pom.xml contains the following
> relevant dependencies:
> akka-actor, akka-remote (both 2.10_2.3.9), typesafe config 1.2.1,
> scala-library 2.10.4.
>
> When I tried to update each dependency to 2.12, each is at:
> akka-actor, akka-remote, akka-cluster-metrics (all at 2.12_2.4.17),
> typesafe config 1.3.1, scala-library 2.12.1.
>
> The earliest jar I can get cluster-metrics for is 2.11 (major version of
> scala still incompatible, afaik). Any configuration of versions I have
> tried result in this same exception. For reference,
> I'm using a Macbook Pro running macOs Sierra 10.12.3. My java version is
> the 'latest' I could get from the oracle site (although I'm confused as
> there seems to be inconsistency between the versions of java listed, I can
> only find one jdk myself).
>
>
> 
>
>
> --
> >> Read the docs: http://akka.io/docs/
> >> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this 

[akka-user] [Akka/Java] Scala exception when updating maven dependencies

2017-04-03 Thread Mark McShane
I'm working on a project making use of various Akka modules in Java 
(akka-actor, akka-remote etc.). These modules were loaded in as 
dependencies through maven, each version being around Akka 2.10:3.9. I left 
the dependencies at these versions as I figured "If it ain't broke then 
don't fix it", and things are working as expected.

I wanted to test some features from akka-cluster-metrics, but I'm have 
problems when I include the dependency in my pom.xml. I suspect the issue 
is some sort of problem with scala major versions. *I'm hoping that perhaps 
someone could give me some advice on how to fix my problem.*

I'm getting the same exception (listed a bit below) regardless of the 
versions of each dependency. The format for the jars 
(see https://mvnrepository.com/) seems to be *akka-_2.:*. At first I thought if I updated the old akka 
2.10 jars to being akka 2.12, the problem would be resolved, but I still 
get the exception.

The exception occurs consistently at the first place akka/scala is used in 
my application, this works fine prior to meddling with dependencies.
final ActorSystem system = ActorSystem.create("QuadraticSystem",
ConfigFactory.parseString("akka.remote.netty.tcp {" +
"\nhostname =\"" + analysisInfo[0] + "\"" +
"\nport=" + analysisInfo[1] +
"\n}").
withFallback(ConfigFactory.load("application.conf")));

A cleaned up form of the exception:
Exception in thread "main" java.lang.VerifyError: Uninitialized object 
exists on backward branch 209
Exception Details:
  Location:

scala/collection/immutable/HashMap$HashTrieMap.split()Lscala/collection/immutable/Seq;
 
@249: goto
  Reason:
Error exists in the bytecode
  Bytecode:
0x000: 2ab6 0057 04a0 001e b200 afb2 00b4 04bd
0x010: 0002 5903 2a53 c000 b6b6 00ba b600 bec0
...
Stackmap Table:
same_frame(@35)
full_frame(@141,{Object[#2],Integer,Integer,Integer,Integer,Integer,Object[#105]},{})
append_frame(@151,Object[#125],Object[#125])
at 
scala.collection.immutable.HashMap$.scala$collection$immutable$HashMap$$makeHashTrieMap(HashMap.scala:179)
at scala.collection.immutable.HashMap$HashMap1.updated0(HashMap.scala:211)
...
at akka.actor.ActorSystem$Settings.(ActorSystem.scala:328)
at akka.actor.ActorSystemImpl.(ActorSystem.scala:683)
at akka.actor.ActorSystem$.apply(ActorSystem.scala:245)
at akka.actor.ActorSystem$.apply(ActorSystem.scala:288)
at akka.actor.ActorSystem$.apply(ActorSystem.scala:263)
at akka.actor.ActorSystem$.create(ActorSystem.scala:191)
at akka.actor.ActorSystem.create(ActorSystem.scala)
at uk.ac.qub.ccrcb.bioinf.ssc.CMDLauncher.main(CMDLauncher.java:38) 

For the record, my existing (working) pom.xml contains the following 
relevant dependencies:
akka-actor, akka-remote (both 2.10_2.3.9), typesafe config 1.2.1, 
scala-library 2.10.4.

When I tried to update each dependency to 2.12, each is at:
akka-actor, akka-remote, akka-cluster-metrics (all at 2.12_2.4.17), 
typesafe config 1.3.1, scala-library 2.12.1.

The earliest jar I can get cluster-metrics for is 2.11 (major version of 
scala still incompatible, afaik). Any configuration of versions I have 
tried result in this same exception. For reference, 
I'm using a Macbook Pro running macOs Sierra 10.12.3. My java version is 
the 'latest' I could get from the oracle site (although I'm confused as 
there seems to be inconsistency between the versions of java listed, I can 
only find one jdk myself).




-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] akka java tutorial , docs is too much messy

2017-03-09 Thread Laxmi Narayan
Hi , 

I really need to use this toolkit with my spring / java Impl. But I am 
really having a real hard time to learn this.

I am not getting any book or youtube channel with akka-java tutorial , I 
have understood basic but still deep concepts 

I am not able to understand , Please let me know if you know any java 
tutorial for akka.

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Akka Java Stream TCP Messaging Simple Example.

2017-01-26 Thread Gaurav Kumar Jayswal
Hi, I need simple tcp messaging example using java akka stream. Can any one 
share the link in which java akka stream + TLS? 

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Akka Java IO TLS

2016-07-18 Thread Vinay Gajjala
Hi 

I am a newbie in Akka and I implemented a TCP server which listens to 
device traffic. I have searched online and could not find any concrete 
examples of how to configure TLS using Akka IO.

I am not sure if I am missing the obvious.

Thanks in advance,
Vinay

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] [akka java 2.4.2] Akka HTTP client oncomplete callback

2016-03-30 Thread Johannes Berg
Hi!

I have a streaming Akka HTTP client request that I would want to register 
an oncomplete callback on (in addition to the streaming which is working 
fine) which is called when the complete request-response is done. There 
doesn't seem to be anything in the Akka HTTP API directly (only toStrict 
method but I can't use that as I need to stream this) but I guess I can be 
looking at when the Akka stream is completed, right? If the stream is 
completed, is the full HTTP request-response completed then (all sockets 
closed and other resources released)?

I'm very new to Akka streams but how can I register an oncomplete callback 
on an Akka stream in Java?

This is roughly what I'm doing and I would want an oncomplete callback when 
it's all done streaming.

Future response_future = Http.get(system).singleRequest(
HttpRequest.create(url), am);
Future> source_future = response_future.map(new Mapper
>() {
public Source apply(HttpResponse response) {
return response.entity().getDataBytes();
}
}, system.dispatcher());

source_future.flatMap(new Mapper, Future>() {
public Future apply(Source source) {
PipedOutputStream output = new PipedOutputStream();
InputStream input = new PipedInputStream(output);

source.to(OutputStreamSink.create(new akka.japi.function.Creator<
OutputStream>() {
public OutputStream create() {
return output;
}
})).run(am);

//doing stuff with input

//how to register oncomplete callback?
source.onComplete ???
}
}, system.dispatcher());

Anyone have any good suggestions?

Thanks,
Johannes

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] [akka java 2.4.2] Future callbacks for already completed futures

2016-03-24 Thread Viktor Klang
You're in luck today—I happen to be a Klang!

What you found is no longer valid and applied to the original Akka Futures.

Thanks for finding this ancient documentation remnant, if you ever see me
at a conference, please let me know and I'll thank you in person. :)



On Thu, Mar 24, 2016 at 3:28 PM, Roland Kuhn  wrote:

> I'm no Klang but I can assure you that all callbacks MUST be dispatched on
> the provided ExecutionContext—otherwise someone will invariably find a way
> to trigger a StackOverflowError. These docs should probably be removed
> completely since we also moved to Scala futures.
>
> Regards,
>
> Roland
>
> Sent from my iPhone
>
> On 24 Mar 2016, at 15:20, Akka Team  wrote:
>
> I have a feeling that that doc remark is obsolete (these sections were not
> touched in years), but let the expert/Klang speak.
>
> -Endre
>
> On Thu, Mar 24, 2016 at 3:18 PM, Johannes Berg  wrote:
>
>> Hi!
>>
>> I've read the documentation at
>> http://doc.akka.io/docs/akka/2.4.2/java/futures.html and where the map
>> function is explained it's stated that "If the Future is already
>> complete though, it will be run in our current thread.". I've just done
>> some tests suggesting this statement would be false, it seems like it's
>> always dispatched on the execution context even though it's already
>> completed.
>>
>> For example this prints two different thread ID:s:
>>
>> System.out.println(Thread.currentThread().getId());
>> Futures.successful(new Object()).map(new Mapper() {
>> public Object apply(Object obj) {
>> System.out.println(Thread.currentThread().getId());
>> }
>> }, system.dispatcher());
>>
>> Indeed I would prefer that behaviour and would like to trust that fact
>> but then the statement in the docs needs to be changed.
>>
>> Can somebody confirm this, I'm happy to create a bug report in github if
>> you think this indeed is a bug in the documentation.
>>
>> I also found some old stuff about this:
>>
>> https://www.assembla.com/spaces/akka/tickets/1054-complete-futures-asynchronously-when-replying-through-a-channel/details#
>> http://blog.ometer.com/2011/07/24/callbacks-synchronous-and-asynchronous/
>>
>> Best Regards,
>> Johannes Berg
>>
>> --
>> >> Read the docs: http://akka.io/docs/
>> >> Check the FAQ:
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >> Search the archives: https://groups.google.com/group/akka-user
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to akka-user+unsubscr...@googlegroups.com.
>> To post to this group, send email to akka-user@googlegroups.com.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Akka Team
> Typesafe - Reactive apps on the JVM
> Blog: letitcrash.com
> Twitter: @akkateam
>
> --
> >> Read the docs: http://akka.io/docs/
> >> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> >> Read the docs: http://akka.io/docs/
> >> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Cheers,
√

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit 

Re: [akka-user] [akka java 2.4.2] Future callbacks for already completed futures

2016-03-24 Thread Johannes Berg
https://github.com/akka/akka/issues/20133

On Thursday, March 24, 2016 at 4:53:10 PM UTC+2, Johannes Berg wrote:
>
> Okay good, thanks, that makes it clear then.
>
> I wouldn't like to see those docs removed altogether though, I always get 
> back there when there's something I've forgot and it explains very well the 
> "java friendly interface in akka.dispatch.Futures" and summarizes quite 
> well what you can do with futures in java code. If this documentation is to 
> be found elsewhere in some Scala documentation (for Java developers) you 
> could just provide a link though.
>
> Thanks,
> Johannes
>
>
> On Thursday, March 24, 2016 at 4:28:47 PM UTC+2, rkuhn wrote:
>>
>> I'm no Klang but I can assure you that all callbacks MUST be dispatched 
>> on the provided ExecutionContext—otherwise someone will invariably find a 
>> way to trigger a StackOverflowError. These docs should probably be removed 
>> completely since we also moved to Scala futures.
>>
>> Regards,
>>
>> Roland 
>>
>> Sent from my iPhone
>>
>> On 24 Mar 2016, at 15:20, Akka Team  wrote:
>>
>> I have a feeling that that doc remark is obsolete (these sections were 
>> not touched in years), but let the expert/Klang speak.
>>
>> -Endre
>>
>> On Thu, Mar 24, 2016 at 3:18 PM, Johannes Berg  wrote:
>>
>>> Hi!
>>>
>>> I've read the documentation at 
>>> http://doc.akka.io/docs/akka/2.4.2/java/futures.html and where the map 
>>> function is explained it's stated that "If the Future is already 
>>> complete though, it will be run in our current thread.". I've just done 
>>> some tests suggesting this statement would be false, it seems like it's 
>>> always dispatched on the execution context even though it's already 
>>> completed.
>>>
>>> For example this prints two different thread ID:s:
>>>
>>> System.out.println(Thread.currentThread().getId());
>>> Futures.successful(new Object()).map(new Mapper() {
>>> public Object apply(Object obj) {
>>> System.out.println(Thread.currentThread().getId());
>>> }
>>> }, system.dispatcher());
>>>
>>> Indeed I would prefer that behaviour and would like to trust that fact 
>>> but then the statement in the docs needs to be changed.
>>>
>>> Can somebody confirm this, I'm happy to create a bug report in github if 
>>> you think this indeed is a bug in the documentation.
>>>
>>> I also found some old stuff about this:
>>>
>>> https://www.assembla.com/spaces/akka/tickets/1054-complete-futures-asynchronously-when-replying-through-a-channel/details#
>>> http://blog.ometer.com/2011/07/24/callbacks-synchronous-and-asynchronous/
>>>
>>> Best Regards,
>>> Johannes Berg
>>>
>>> -- 
>>> >> Read the docs: http://akka.io/docs/
>>> >> Check the FAQ: 
>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>> >> Search the archives: 
>>> https://groups.google.com/group/akka-user
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Akka User List" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to akka-user+...@googlegroups.com.
>>> To post to this group, send email to akka...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/akka-user.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> Akka Team
>> Typesafe - Reactive apps on the JVM
>> Blog: letitcrash.com
>> Twitter: @akkateam
>>
>> -- 
>> >> Read the docs: http://akka.io/docs/
>> >> Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >> Search the archives: https://groups.google.com/group/akka-user
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to akka-user+...@googlegroups.com.
>> To post to this group, send email to akka...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] [akka java 2.4.2] Future callbacks for already completed futures

2016-03-24 Thread Johannes Berg
Okay good, thanks, that makes it clear then.

I wouldn't like to see those docs removed altogether though, I always get 
back there when there's something I've forgot and it explains very well the 
"java friendly interface in akka.dispatch.Futures" and summarizes quite 
well what you can do with futures in java code. If this documentation is to 
be found elsewhere in some Scala documentation (for Java developers) you 
could just provide a link though.

Thanks,
Johannes


On Thursday, March 24, 2016 at 4:28:47 PM UTC+2, rkuhn wrote:
>
> I'm no Klang but I can assure you that all callbacks MUST be dispatched on 
> the provided ExecutionContext—otherwise someone will invariably find a way 
> to trigger a StackOverflowError. These docs should probably be removed 
> completely since we also moved to Scala futures.
>
> Regards,
>
> Roland 
>
> Sent from my iPhone
>
> On 24 Mar 2016, at 15:20, Akka Team  
> wrote:
>
> I have a feeling that that doc remark is obsolete (these sections were not 
> touched in years), but let the expert/Klang speak.
>
> -Endre
>
> On Thu, Mar 24, 2016 at 3:18 PM, Johannes Berg  > wrote:
>
>> Hi!
>>
>> I've read the documentation at 
>> http://doc.akka.io/docs/akka/2.4.2/java/futures.html and where the map 
>> function is explained it's stated that "If the Future is already 
>> complete though, it will be run in our current thread.". I've just done 
>> some tests suggesting this statement would be false, it seems like it's 
>> always dispatched on the execution context even though it's already 
>> completed.
>>
>> For example this prints two different thread ID:s:
>>
>> System.out.println(Thread.currentThread().getId());
>> Futures.successful(new Object()).map(new Mapper() {
>> public Object apply(Object obj) {
>> System.out.println(Thread.currentThread().getId());
>> }
>> }, system.dispatcher());
>>
>> Indeed I would prefer that behaviour and would like to trust that fact 
>> but then the statement in the docs needs to be changed.
>>
>> Can somebody confirm this, I'm happy to create a bug report in github if 
>> you think this indeed is a bug in the documentation.
>>
>> I also found some old stuff about this:
>>
>> https://www.assembla.com/spaces/akka/tickets/1054-complete-futures-asynchronously-when-replying-through-a-channel/details#
>> http://blog.ometer.com/2011/07/24/callbacks-synchronous-and-asynchronous/
>>
>> Best Regards,
>> Johannes Berg
>>
>> -- 
>> >> Read the docs: http://akka.io/docs/
>> >> Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >> Search the archives: https://groups.google.com/group/akka-user
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to akka-user+...@googlegroups.com .
>> To post to this group, send email to akka...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Akka Team
> Typesafe - Reactive apps on the JVM
> Blog: letitcrash.com
> Twitter: @akkateam
>
> -- 
> >> Read the docs: http://akka.io/docs/
> >> Check the FAQ: 
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >> Search the archives: https://groups.google.com/group/akka-user
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to akka-user+...@googlegroups.com .
> To post to this group, send email to akka...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>
>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] [akka java 2.4.2] Future callbacks for already completed futures

2016-03-24 Thread Roland Kuhn
I'm no Klang but I can assure you that all callbacks MUST be dispatched on the 
provided ExecutionContext—otherwise someone will invariably find a way to 
trigger a StackOverflowError. These docs should probably be removed completely 
since we also moved to Scala futures.

Regards,

Roland 

Sent from my iPhone

> On 24 Mar 2016, at 15:20, Akka Team  wrote:
> 
> I have a feeling that that doc remark is obsolete (these sections were not 
> touched in years), but let the expert/Klang speak.
> 
> -Endre
> 
>> On Thu, Mar 24, 2016 at 3:18 PM, Johannes Berg  wrote:
>> Hi!
>> 
>> I've read the documentation at 
>> http://doc.akka.io/docs/akka/2.4.2/java/futures.html and where the map 
>> function is explained it's stated that "If the Future is already complete 
>> though, it will be run in our current thread.". I've just done some tests 
>> suggesting this statement would be false, it seems like it's always 
>> dispatched on the execution context even though it's already completed.
>> 
>> For example this prints two different thread ID:s:
>> 
>> System.out.println(Thread.currentThread().getId());
>> Futures.successful(new Object()).map(new Mapper() {
>> public Object apply(Object obj) {
>> System.out.println(Thread.currentThread().getId());
>> }
>> }, system.dispatcher());
>> 
>> Indeed I would prefer that behaviour and would like to trust that fact but 
>> then the statement in the docs needs to be changed.
>> 
>> Can somebody confirm this, I'm happy to create a bug report in github if you 
>> think this indeed is a bug in the documentation.
>> 
>> I also found some old stuff about this:
>> https://www.assembla.com/spaces/akka/tickets/1054-complete-futures-asynchronously-when-replying-through-a-channel/details#
>> http://blog.ometer.com/2011/07/24/callbacks-synchronous-and-asynchronous/
>> 
>> Best Regards,
>> Johannes Berg
>> -- 
>> >> Read the docs: http://akka.io/docs/
>> >> Check the FAQ: 
>> >> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >> Search the archives: https://groups.google.com/group/akka-user
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to akka-user+unsubscr...@googlegroups.com.
>> To post to this group, send email to akka-user@googlegroups.com.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
> 
> 
> 
> -- 
> Akka Team
> Typesafe - Reactive apps on the JVM
> Blog: letitcrash.com
> Twitter: @akkateam
> -- 
> >> Read the docs: http://akka.io/docs/
> >> Check the FAQ: 
> >> http://doc.akka.io/docs/akka/current/additional/faq.html
> >> Search the archives: https://groups.google.com/group/akka-user
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] [akka java 2.4.2] Future callbacks for already completed futures

2016-03-24 Thread Akka Team
I have a feeling that that doc remark is obsolete (these sections were not
touched in years), but let the expert/Klang speak.

-Endre

On Thu, Mar 24, 2016 at 3:18 PM, Johannes Berg  wrote:

> Hi!
>
> I've read the documentation at
> http://doc.akka.io/docs/akka/2.4.2/java/futures.html and where the map
> function is explained it's stated that "If the Future is already complete
> though, it will be run in our current thread.". I've just done some tests
> suggesting this statement would be false, it seems like it's always
> dispatched on the execution context even though it's already completed.
>
> For example this prints two different thread ID:s:
>
> System.out.println(Thread.currentThread().getId());
> Futures.successful(new Object()).map(new Mapper() {
> public Object apply(Object obj) {
> System.out.println(Thread.currentThread().getId());
> }
> }, system.dispatcher());
>
> Indeed I would prefer that behaviour and would like to trust that fact but
> then the statement in the docs needs to be changed.
>
> Can somebody confirm this, I'm happy to create a bug report in github if
> you think this indeed is a bug in the documentation.
>
> I also found some old stuff about this:
>
> https://www.assembla.com/spaces/akka/tickets/1054-complete-futures-asynchronously-when-replying-through-a-channel/details#
> http://blog.ometer.com/2011/07/24/callbacks-synchronous-and-asynchronous/
>
> Best Regards,
> Johannes Berg
>
> --
> >> Read the docs: http://akka.io/docs/
> >> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Akka Team
Typesafe - Reactive apps on the JVM
Blog: letitcrash.com
Twitter: @akkateam

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] [akka java 2.4.2] Future callbacks for already completed futures

2016-03-24 Thread Johannes Berg
Hi!

I've read the documentation at 
http://doc.akka.io/docs/akka/2.4.2/java/futures.html and where the map 
function is explained it's stated that "If the Future is already complete 
though, it will be run in our current thread.". I've just done some tests 
suggesting this statement would be false, it seems like it's always 
dispatched on the execution context even though it's already completed.

For example this prints two different thread ID:s:

System.out.println(Thread.currentThread().getId());
Futures.successful(new Object()).map(new Mapper() {
public Object apply(Object obj) {
System.out.println(Thread.currentThread().getId());
}
}, system.dispatcher());

Indeed I would prefer that behaviour and would like to trust that fact but 
then the statement in the docs needs to be changed.

Can somebody confirm this, I'm happy to create a bug report in github if 
you think this indeed is a bug in the documentation.

I also found some old stuff about this:
https://www.assembla.com/spaces/akka/tickets/1054-complete-futures-asynchronously-when-replying-through-a-channel/details#
http://blog.ometer.com/2011/07/24/callbacks-synchronous-and-asynchronous/

Best Regards,
Johannes Berg

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] [akka java 2.4.2] creating a flow sending elements of the stream to given actorRef and pushing results back to stream

2016-03-06 Thread paweł kamiński
hi,
I have a simple HTTP service that accepts connections and keeps them alive. 
Once client sends something I look-up actorRef (WORKER) based on path/query 
of request and I would like to wait for response from such actor so I can 
respond back to client. 

this is server to server communication so there should be one connection 
per machine but there will be situation where same path/query is sent by 
more then one connection.
(in other words one worker should be able to update more than one stream 
created by accepted connection - if this is even possible).
A worker can only produce result if other actor sent it data in first 
place, worker cannot produce results by itself. I want a worker to 
represent client in akka system. 

The problem I am facing is that I cannot figure out how to create such flow 
that gets HttpRequest and produces HttpResponse and in the middle sends 
incoming request to actor and waits for response.
so far I came with such code

public void start() {
Source serverSource = 
Http
.get(system)
.bind(ConnectHttp.toHost("localhost", port), materializer);

Flow failureDetection = 
Flow
.of(IncomingConnection.class)
.watchTermination((_unused, termination) -> {
termination.whenComplete((done, cause) -> {
if (cause != null) {
log.error("Connection was closed.", cause);
}
});
return NotUsed.getInstance();
});

serverSource
.via(failureDetection)

// <--- send each new connection to actorRef
.to(Sink.actorRef(connectionRouter, closeConnectionMsg)) 
.run(materializer)
.whenCompleteAsync((binding, failure) -> {
if (failure != null) {
log.error("Could not initialize connection.", failure);
}
}, system.dispatcher());
}


// ConnectionRouter receive definition

receive(ReceiveBuilder
.match(IncomingConnection.class, connection -> {
Flow updateRequestFlow = Flow

.of(HttpRequest.class)

.map(request -> {
String mime = request.getHeader(Accept.class)

.map(HttpHeader::value)

.orElse("application/json");


if (!isAcceptable(mime)) {

return HttpResponse.create()

.withStatus(StatusCodes.NOT_ACCEPTABLE)

.addHeader(RawHeader.create("Connection", "close"))

.addHeader(RawHeader.create("Content-Length", "0"));

}


Query query = request.getUri().query();

Optional idOp = query.get("id");

if (!idOp.isPresent()) {

return HttpResponse.create()

.withStatus(StatusCodes.BAD_REQUEST)

.addHeader(RawHeader.create("Connection", "close"))

.addHeader(RawHeader.create("Content-Length", "0"));

}


String id = idOp.get();

// <--- retrieve or create new worker based on ID (it is 
limited set of ids)

ActorRef worker = actorsMap.get(id);


// NOW worker.tell(READY_TO_GET_DATA_MSG) should eventually 
create some result that should be mapped to response


byte[] bytes = toBytes(mime, RESULT_PRODUCED_BY_WORKER);

String length = Integer.toString(bytes.length);

return HttpResponse.create()

.withStatus(StatusCodes.OK)

.withEntity(HttpEntities.create(bytes))

.addHeader(RawHeader.create("Connection", "keep-alive"))

.addHeader(RawHeader.create("Content-Length", length))

.addHeader(RawHeader.create("Content-Type", mime));

});

connection.handleWith(updateRequestFlow, materializer);
})
.build());


is this even possible with current akka-http / streams ? I have been looking 
into http://doc.akka.io/docs/akka/2.4.2/java/stream/stream-integrations.html 
but mapAsync is rather not my use-case, ActorPublisher maybe would help but I 
cannot make it fit into described flow.

thanks for any ideas.



-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 

[akka-user] [akka java streams] trouble with the type system

2016-01-18 Thread john . vieten



Just curious the following code (adapted from 
"http://doc.akka.io/docs/akka-stream-and-http-experimental/2.0.2/java/stream-graphs.html;)
 compile fails with
an Error: 
java: incompatible types: 
akka.stream.UniformFanOutShape cannot be 
converted to akka.stream.UniformFanOutShape

if I change 
final UniformFanOutShape bcast = (UniformFanOutShape)builder.add(Broadcast.create(2));
to 
final UniformFanOutShape bcast = 
builder.add(Broadcast.create(2));

everything works.

Can Anybody explain to me what's the reason?


import akka.stream.ClosedShape;

import akka.stream.UniformFanOutShape;
import akka.stream.javadsl.*;
import scala.concurrent.Future;
import java.util.List;

public class Main {

   public static void main(String[] args) {
  final Sink> sink = Sink.head();


  final RunnableGraph> result =
RunnableGraph.>fromGraph(
  GraphDSL
.create(
  sink,
  (builder, out) -> {
 final UniformFanOutShape 
bcast = (UniformFanOutShape)builder.add(Broadcast.create(2));
 return ClosedShape.getInstance();
  }));
  
   }
}

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] [akka java streams] trouble with the type system

2016-01-18 Thread john . vieten
Hi Roland,
thanks alot. I am kind of trying to learn scala from reading the 
akka-streams-javadsl and sometimes get stuck by simmple things

Am Montag, 18. Januar 2016 10:31:28 UTC+1 schrieb rkuhn:
>
> Hi John,
>
> you’ll need to tell javac a bit more about that Broadcast by saying
>
> Broadcast. create(2)
>
> Regards,
>
> Roland
>
> 18 jan 2016 kl. 10:25 skrev john@gmail.com :
>
>
> Just curious the following code (adapted from 
> "http://doc.akka.io/docs/akka-stream-and-http-experimental/2.0.2/java/stream-graphs.html;)
>  compile fails with
> an Error: 
> java: incompatible types: 
> akka.stream.UniformFanOutShape cannot be 
> converted to 
> akka.stream.UniformFanOutShape
>
> if I change 
> final UniformFanOutShape bcast = 
> (UniformFanOutShape)builder.add(Broadcast.create(2));
> to 
> final UniformFanOutShape bcast = 
> builder.add(Broadcast.create(2));
>
> everything works.
>
> Can Anybody explain to me what's the reason?
>
>
> import akka.stream.ClosedShape;
>
> import akka.stream.UniformFanOutShape;
> import akka.stream.javadsl.*;
> import scala.concurrent.Future;
> import java.util.List;
>
> public class Main {
>
>public static void main(String[] args) {
>   final Sink> sink = Sink.head();
>
>
>   final RunnableGraph> result =
> RunnableGraph.>fromGraph(
>   GraphDSL
> .create(
>   sink,
>   (builder, out) -> {
>  final UniformFanOutShape 
> bcast = (UniformFanOutShape Integer>)builder.add(Broadcast.create(2));
>  return ClosedShape.getInstance();
>   }));
>   
>}
> }
>
>
> -- 
> >> Read the docs: http://akka.io/docs/
> >> Check the FAQ: 
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >> Search the archives: https://groups.google.com/group/akka-user
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to akka-user+...@googlegroups.com .
> To post to this group, send email to akka...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> *Dr. Roland Kuhn*
> *Akka Tech Lead*
> Typesafe  – Reactive apps on the JVM.
> twitter: @rolandkuhn
> 
>
>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] [akka java streams] trouble with the type system

2016-01-18 Thread Roland Kuhn
Hi John,

you’ll need to tell javac a bit more about that Broadcast by saying

Broadcast. create(2)

Regards,

Roland

> 18 jan 2016 kl. 10:25 skrev john.vie...@gmail.com:
> 
> 
> Just curious the following code (adapted from 
> "http://doc.akka.io/docs/akka-stream-and-http-experimental/2.0.2/java/stream-graphs.html;)
>  compile fails with
> an Error: 
> java: incompatible types: 
> akka.stream.UniformFanOutShape cannot be 
> converted to 
> akka.stream.UniformFanOutShape
> 
> if I change 
> final UniformFanOutShape bcast = 
> (UniformFanOutShape)builder.add(Broadcast.create(2));
> to 
> final UniformFanOutShape bcast = 
> builder.add(Broadcast.create(2));
> 
> everything works.
> 
> Can Anybody explain to me what's the reason?
> 
> 
> import akka.stream.ClosedShape;
> 
> import akka.stream.UniformFanOutShape;
> import akka.stream.javadsl.*;
> import scala.concurrent.Future;
> import java.util.List;
> 
> public class Main {
> 
>public static void main(String[] args) {
>   final Sink> sink = Sink.head();
> 
> 
>   final RunnableGraph> result =
> RunnableGraph.>fromGraph(
>   GraphDSL
> .create(
>   sink,
>   (builder, out) -> {
>  final UniformFanOutShape 
> bcast = (UniformFanOutShape Integer>)builder.add(Broadcast.create(2));
>  return ClosedShape.getInstance();
>   }));
>   
>}
> }
> 
> -- 
> >> Read the docs: http://akka.io/docs/ 
> >> Check the FAQ: 
> >> http://doc.akka.io/docs/akka/current/additional/faq.html 
> >> 
> >> Search the archives: https://groups.google.com/group/akka-user 
> >> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to akka-user+unsubscr...@googlegroups.com 
> .
> To post to this group, send email to akka-user@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/akka-user 
> .
> For more options, visit https://groups.google.com/d/optout 
> .



Dr. Roland Kuhn
Akka Tech Lead
Typesafe  – Reactive apps on the JVM.
twitter: @rolandkuhn
 

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Akka Java Remote

2015-10-01 Thread Korri Gnu
Hi,

I'm new to Akka and I'm trying to play with it. However I'm stuck with the 
java remote sample...


In command line, I run in two different shells
java -cp 
bin:akka-actor_2.10-3.14.jar:config-2.1.2.jar:akka-remote_2.10-2.3.14.jar:scala-library-2.10.4.jar
 
remote.calculator.LookupApplication Calculator
java -cp 
bin:akka-actor_2.10-3.14.jar:config-2.1.2.jar:akka-remote_2.10-2.3.14.jar:scala-library-2.10.4.jar
 
remote.calculator.LookupApplication Lookup

Calculator shell do nothing while Lookup shell is endless looping, 
repeating RemoteActor not available, not ready yet...

If I check on a third shell if their is a process listening on ports 2552 
or 2553 (telnet/lsof/netstat or nmap) there is nothing...
So it seems that my programs are running locally and thus are not aware ot 
the presence of the other actor...

my configuration files seems to identical to the one provided on the 
website...

Any clue to help me ?
Thanks by advance

K.

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Akka java newbie : Managing different routess within an actor

2015-08-03 Thread apo
Hi,

In the documentation Akka Java documentation : Routing [A Simple Router], 
ti's discussing how to manage routees whenever it's being terminated. The 
sample only deals with 1 router with 5 routees. In my case I'm doing 2 
routers with 5 routees each like this:

Akka 2.3.12



public class Processor extends UntypedActor {
private Router udpParserRouter;
private Router objectParserRouter;

public Processor() {

// UDP Parser Router
ListRoutee udpRoutees = new ArrayListRoutee();
for (int i = 0; i  5; i++) {
ActorRef udpParser = 
context().actorOf(Props.create(UdpParser.class), udpParser + 1);
getContext().watch(udpParser);
udpRoutees.add(new ActorRefRoutee(udpParser));
}
udpParserRouter = new Router(new RoundRobinRoutingLogic(), 
updRoutees);

// Object Parser Router
ListRoutee objRoutees = new ArrayListRoutee();
for (int i = 0; i  5; i++) {
ActorRef objParser = 
context().actorOf(Props.create(ObjectParser.class), objParser + i);
getContext().watch(objParser);
objRoutees.add(new ActorRefRoutee(objParser));
}
objectParserRouter = new Router(new RoundRobinRoutingLogic(), 
objRoutees);
}

@Override
public void onReceive(Object mesg) throws Exception {
if (mesg instanceof Terminated) {
final Terminated t = (Terminated) mesg;
ActorRef deadActorRef = t.actor();

code to handle restarting udpParser or objParser routees
}
}
}

I'm not sure how to distinguished between udpParser and objParser so 
that I can restart it properly.

Here what I'm thinking of doing:
- make udpParser and objParser as member fields and add the code below 
in the onReceived() method

if (deadActorRef.equals(udpParser) {
udpParserRouter = udpParserRouter.removeRoutee(((Terminated) 
mesg).actor());
udpParser = 
getContext().actorOf(Props.create(TRACEUdpParser.class));
getContext().watch(udpParser);
udpParserRouter = udpParserRouter.addRoutee(new 
ActorRefRoutee(udpParser));
} else if (deadActorRef.equals(objParser)) {
objectParserRouter = udpParserRouter.removeRoutee(((Terminated) 
mesg).actor());
objParser = 
getContext().actorOf(Props.create(TRACEObjectModelParser.class));
getContext().watch(objParser);
objectParserRouter = objectParserRouter.addRoutee(new 
ActorRefRoutee(objParser));
}

Is there a better way of doing this?

Thanks.

-- 
  Read the docs: http://akka.io/docs/
  Check the FAQ: 
 http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups Akka 
User List group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Akka Java API vs Scala, any performance difference?

2015-06-07 Thread Akka Team
Hi Guido,

There is no overhead of calling Scala code from Java, whatever you can
access from Java, and looks like a method, then it is an ordinary JVM
method. In fact, sometimes calling the Scala API might be slightly faster,
since most of the time the Java API just calls the Scala API underneath
anyway.

-Endre

On Tue, Jun 2, 2015 at 12:29 PM, Guido Medina oxyg...@gmail.com wrote:

 Hi,

 I like the mix between Java and Scala and sometimes even more inclined to
 Scala idiom, assume that we will eventually move from Java 8 to Scala but
 for now we are stuck with Java 8, using the following two examples:


   // Method using Scala API
   private void applyToAccount(Currency currency, BalanceOperation
 operation) {
 final ActorContext context = context();
 context.child(currency.code).
   getOrElse(new AbstractFunction0ActorRef() {
 @Override
 public ActorRef apply() {
   return context.actorOf(balancePersistorProps(currency), currency
 .code);
 }
   }).forward(operation, context);
   }


   // Method using Java 8 API, the following is shorter in Java because
 Scala Option
   // is not functional interface but that's an exception so probably not
 the best example.
   private void applyToAccount(Currency currency, BalanceOperation
 operation) {
 final UntypedActorContext context = getContext();
 Optional.ofNullable(context.getChild(currency.code)).
   orElseGet(() - context.actorOf(balancePersistorProps(currency),
 currency.code)).
   forward(operation, context);
   }

 Is there a performance difference in Akka between calling Java-to-Java vs
 Java-to-Scala?, I really hate to do things like getContext(), getChild(),
 get..., get..., get..., stupid get in front of everything so I'm just
 mixing Java/Scala together, is there anything I should be aware of or
 counter indicated with my approach/taste/convention?

 --
  Read the docs: http://akka.io/docs/
  Check the FAQ:
 http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user
 ---
 You received this message because you are subscribed to the Google Groups
 Akka User List group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to akka-user+unsubscr...@googlegroups.com.
 To post to this group, send email to akka-user@googlegroups.com.
 Visit this group at http://groups.google.com/group/akka-user.
 For more options, visit https://groups.google.com/d/optout.




-- 
Akka Team
Typesafe - Reactive apps on the JVM
Blog: letitcrash.com
Twitter: @akkateam

-- 
  Read the docs: http://akka.io/docs/
  Check the FAQ: 
 http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups Akka 
User List group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Akka Java Future onSuccess and onFail run on which thread context

2014-12-04 Thread Wanghong Li
dear all,
I have two actor A and B. When A send a message to B and must wait for 
response. And I know I can use ask to implement this. But it will block the 
thread. So future.onSuccess and future.onFailure must be a good way. I 
don't know the callback onSuccess or onFailure runs on A or B's thread 
context, even I should invoke  akka.pattern.Patterns.pipe(future, system.
dispatcher()).to(actor) to switch to A's context.

-- 
  Read the docs: http://akka.io/docs/
  Check the FAQ: 
 http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups Akka 
User List group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Akka Java Future onSuccess and onFail run on which thread context

2014-12-04 Thread Akka Team
Hi,

onSuccess or onFailure runs on any of the threads that are available in the
underlying ExecutionContext. An actor does not have a thread, although it
gets one for execution when there are messages to process, but then it
gives back that thread to the underlying pool. You should definitely not
Await on the future you have, but you should use the pipe mechanism to send
the result to the actor: myFuture.pipeTo(self)

Then the actor will get the result as a message when the future has been
completed. If there was a faillure, it will get an akka.actor.Failure
message with the failure cause included (
http://doc.akka.io/api/akka/2.3.7/#akka.actor.Status$$Failure).

In general it is recommended to use message sends instead of ask. Actor A
can simply send a message: B ! RequestSomething
Then actor A can handle the reply as a normal message in the receive block.

-Endre

On Thu, Dec 4, 2014 at 10:41 AM, Wanghong Li yuanhong1...@gmail.com wrote:

 dear all,
 I have two actor A and B. When A send a message to B and must wait for
 response. And I know I can use ask to implement this. But it will block the
 thread. So future.onSuccess and future.onFailure must be a good way. I
 don't know the callback onSuccess or onFailure runs on A or B's thread
 context, even I should invoke  akka.pattern.Patterns.pipe(future, system.
 dispatcher()).to(actor) to switch to A's context.

 --
  Read the docs: http://akka.io/docs/
  Check the FAQ:
 http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user
 ---
 You received this message because you are subscribed to the Google Groups
 Akka User List group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to akka-user+unsubscr...@googlegroups.com.
 To post to this group, send email to akka-user@googlegroups.com.
 Visit this group at http://groups.google.com/group/akka-user.
 For more options, visit https://groups.google.com/d/optout.




-- 
Akka Team
Typesafe - The software stack for applications that scale
Blog: letitcrash.com
Twitter: @akkateam

-- 
  Read the docs: http://akka.io/docs/
  Check the FAQ: 
 http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups Akka 
User List group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Akka Java future onComplete and onFailure syntax . Not compiling using doc example.

2014-07-01 Thread √iktor Ҡlang
Did you import it properly?

API docs are here:
http://doc.akka.io/japi/akka/2.3.4/?_ga=1.248190663.1579561034.1353497989


On Tue, Jul 1, 2014 at 2:00 PM, claude hussenet chusse...@gmail.com wrote:

 Have no problem to implement the onSuccess method based on the doc ,but
 getting compilation issue for the onComplete and onFailure.


 // THE FOLLOWING COMPILE AND WORKS

  final FutureActorRef ft = remoteActor.resolveOne(timeout);

 ExecutionContext ec = system.dispatcher();

   ft.onSuccess(new OnSuccessActorRef() {

public void onSuccess(ActorRef remoteActor) throws Exception  {

   //   DO SOME WORK HERE

}

   },

  ec);

 //THE FOLLOWING TOOK  DOES NOT COMPILE  ..GETTING ERROR OnComplete can not
 be resolved to a type

   ft.onComplete(new OnComplete ActorRef () {

public void onComplete(Throwable failure, ActorRef remoteRef) {

  if (failure != null) {

//We got a failure, handle it here

  } else {

// We got a result, do something with it

  }

}

  }, ec);

 --
  Read the docs: http://akka.io/docs/
  Check the FAQ:
 http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user
 ---
 You received this message because you are subscribed to the Google Groups
 Akka User List group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to akka-user+unsubscr...@googlegroups.com.
 To post to this group, send email to akka-user@googlegroups.com.
 Visit this group at http://groups.google.com/group/akka-user.
 For more options, visit https://groups.google.com/d/optout.




-- 
Cheers,
√

-- 
  Read the docs: http://akka.io/docs/
  Check the FAQ: 
 http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups Akka 
User List group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Akka Java : Supervisor strategy

2014-07-01 Thread Yadukrishnan K
I am a newbie to akka actor system. I am developing an application using 
Java, Spring, Hibernate and Akka. 
I am having problems with exception handling. 

My scenario is given below :

REST API -- Spring MVC -- Service Layer (Actor) -- Hibernate Repository.
Assume that I am trying to find an employee with id 1. 

Employee emp = HibernateRepository.findById(Employee.class, id);
sender().tell(emp, self());

If the employee with id=1 doesn't exist, the emp object will be NULL and 
sending NULL as message will throw InvalidMessageException. 
Is it possible to handle this exception and throw a custom Exception to the 
caller, say NoEntityFoundException? This help me to check if the result I 
obtained is of Employee or CustomException. Currently, I am getting Future 
timeout only. 

I have a BaseActor which extends akka.actor.AbstractActor. I also have 
another class, BaseModuleActor which extends BaseActor, as shown below.

public class BaseModuleActor extends BaseActor {

public  T ActorRef getActorRef(ActorSystem system,ClassT clazz){
return system.actorOf(
SpringExtension.SpringExtProvider.get(system).props(clazz));
}
}

All my actors are extending this actor, where I am doing like below

@Override
public PartialFunctionObject, BoxedUnit receive(){
  return ReceiveBuilder
  .match(Long.class, id- getEmployeeById(id))
  .build()
  .orElse(matchAny());
}
private void getEmployeeById(Long id){
   Employee emp = HibernateRepository.findById(Employee.class, id);
   sender().tell(emp, self());
}


But I am now stuck with handling the exceptions at a common place using the 
supervisor strategy. 
How can I catch the InvalidMessageException and resends some meaningful 
message to the caller. Is it possible? 


Regards,
Yadu

-- 
  Read the docs: http://akka.io/docs/
  Check the FAQ: 
 http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups Akka 
User List group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Akka Java : Supervisor strategy

2014-07-01 Thread √iktor Ҡlang
On Tue, Jul 1, 2014 at 2:57 PM, Yadukrishnan K yadava...@gmail.com wrote:

 I am a newbie to akka actor system. I am developing an application using
 Java, Spring, Hibernate and Akka.
 I am having problems with exception handling.

 My scenario is given below :

 REST API -- Spring MVC -- Service Layer (Actor) -- Hibernate Repository.
 Assume that I am trying to find an employee with id 1.

 Employee emp = HibernateRepository.findById(Employee.class, id);
 sender().tell(emp, self());

 If the employee with id=1 doesn't exist, the emp object will be NULL and
 sending NULL as message will throw InvalidMessageException.
 Is it possible to handle this exception and throw a custom Exception to
 the caller, say NoEntityFoundException? This help me to check if the result
 I obtained is of Employee or CustomException. Currently, I am getting
 Future timeout only.

 I have a BaseActor which extends akka.actor.AbstractActor. I also have
 another class, BaseModuleActor which extends BaseActor, as shown below.

 public class BaseModuleActor extends BaseActor {

 public  T ActorRef getActorRef(ActorSystem system,ClassT clazz){
 return system.actorOf(

 SpringExtension.SpringExtProvider.get(system).props(clazz));
 }
 }

 All my actors are extending this actor, where I am doing like below

 @Override
 public PartialFunctionObject, BoxedUnit receive(){
   return ReceiveBuilder
   .match(Long.class, id- getEmployeeById(id))
   .build()
   .orElse(matchAny());
 }
 private void getEmployeeById(Long id){
Employee emp = HibernateRepository.findById(Employee.class, id);


sender().tell((emp != null) ? new EmployeeFound(emp) : new
NoSuchEmployee(id), self());


sender().tell(emp, self());
 }


 But I am now stuck with handling the exceptions at a common place using
 the supervisor strategy.
 How can I catch the InvalidMessageException and resends some meaningful
 message to the caller. Is it possible?


 Regards,
 Yadu

 --
  Read the docs: http://akka.io/docs/
  Check the FAQ:
 http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user
 ---
 You received this message because you are subscribed to the Google Groups
 Akka User List group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to akka-user+unsubscr...@googlegroups.com.
 To post to this group, send email to akka-user@googlegroups.com.
 Visit this group at http://groups.google.com/group/akka-user.
 For more options, visit https://groups.google.com/d/optout.




-- 
Cheers,
√

-- 
  Read the docs: http://akka.io/docs/
  Check the FAQ: 
 http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups Akka 
User List group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Akka Java future onComplete and onFailure syntax . Not compiling using doc example.

2014-07-01 Thread claude hussenet
Thank you.It works.

For whatever my editor could not complete and include the missing classes 
such as  

import akka.dispatch.OnComplete;

Claude

On Tuesday, July 1, 2014 8:10:14 AM UTC-4, √ wrote:

 Did you import it properly?

 API docs are here: 
 http://doc.akka.io/japi/akka/2.3.4/?_ga=1.248190663.1579561034.1353497989


 On Tue, Jul 1, 2014 at 2:00 PM, claude hussenet chus...@gmail.com 
 javascript: wrote:

 Have no problem to implement the onSuccess method based on the doc ,but 
 getting compilation issue for the onComplete and onFailure.


 // THE FOLLOWING COMPILE AND WORKS

  final FutureActorRef ft = remoteActor.resolveOne(timeout);  

 ExecutionContext ec = system.dispatcher();

   ft.onSuccess(new OnSuccessActorRef() {

public void onSuccess(ActorRef remoteActor) throws Exception  {

   //   DO SOME WORK HERE

}

   }, 

  ec);

 //THE FOLLOWING TOOK  DOES NOT COMPILE  ..GETTING ERROR OnComplete can 
 not be resolved to a type

   ft.onComplete(new OnComplete ActorRef () {

public void onComplete(Throwable failure, ActorRef remoteRef) {

  if (failure != null) {

//We got a failure, handle it here

  } else {

// We got a result, do something with it

  }

}

  }, ec);

 -- 
  Read the docs: http://akka.io/docs/
  Check the FAQ: 
 http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user
 --- 
 You received this message because you are subscribed to the Google Groups 
 Akka User List group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to akka-user+...@googlegroups.com javascript:.
 To post to this group, send email to akka...@googlegroups.com 
 javascript:.
 Visit this group at http://groups.google.com/group/akka-user.
 For more options, visit https://groups.google.com/d/optout.




 -- 
 Cheers,
 √
  

-- 
  Read the docs: http://akka.io/docs/
  Check the FAQ: 
 http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups Akka 
User List group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Akka Java future onComplete and onFailure syntax . Not compiling using doc example.

2014-07-01 Thread √iktor Ҡlang
Excellent, happy hAkking!
On Jul 1, 2014 6:53 PM, claude hussenet chusse...@gmail.com wrote:

 Thank you.It works.

 For whatever my editor could not complete and include the missing classes
 such as

 import akka.dispatch.OnComplete;

 Claude

 On Tuesday, July 1, 2014 8:10:14 AM UTC-4, √ wrote:

 Did you import it properly?

 API docs are here: http://doc.akka.io/japi/akka/2.3.4/?_ga=1.248190663.
 1579561034.1353497989


 On Tue, Jul 1, 2014 at 2:00 PM, claude hussenet chus...@gmail.com
 wrote:

 Have no problem to implement the onSuccess method based on the doc ,but
 getting compilation issue for the onComplete and onFailure.


 // THE FOLLOWING COMPILE AND WORKS

  final FutureActorRef ft = remoteActor.resolveOne(timeout);

 ExecutionContext ec = system.dispatcher();

   ft.onSuccess(new OnSuccessActorRef() {

public void onSuccess(ActorRef remoteActor) throws Exception  {

   //   DO SOME WORK HERE

}

   },

  ec);

 //THE FOLLOWING TOOK  DOES NOT COMPILE  ..GETTING ERROR OnComplete can
 not be resolved to a type

   ft.onComplete(new OnComplete ActorRef () {

public void onComplete(Throwable failure, ActorRef remoteRef) {

  if (failure != null) {

//We got a failure, handle it here

  } else {

// We got a result, do something with it

  }

}

  }, ec);

 --
  Read the docs: http://akka.io/docs/
  Check the FAQ: http://doc.akka.io/docs/akka/
 current/additional/faq.html
  Search the archives: https://groups.google.com/
 group/akka-user
 ---
 You received this message because you are subscribed to the Google
 Groups Akka User List group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to akka-user+...@googlegroups.com.
 To post to this group, send email to akka...@googlegroups.com.
 Visit this group at http://groups.google.com/group/akka-user.
 For more options, visit https://groups.google.com/d/optout.




 --
 Cheers,
 √

  --
  Read the docs: http://akka.io/docs/
  Check the FAQ:
 http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user
 ---
 You received this message because you are subscribed to the Google Groups
 Akka User List group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to akka-user+unsubscr...@googlegroups.com.
 To post to this group, send email to akka-user@googlegroups.com.
 Visit this group at http://groups.google.com/group/akka-user.
 For more options, visit https://groups.google.com/d/optout.


-- 
  Read the docs: http://akka.io/docs/
  Check the FAQ: 
 http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups Akka 
User List group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Akka (Java) Competing Consumers

2014-05-05 Thread Akka Team
Hi,

I see that you create a router with a set of workers:


// distributing the message processing across a pool of 5 actors
 ActorRef workRouter =
   akkaSystem.actorOf(new
 RoundRobinPool(numOfWorkers).props(Props.create(EventProcessor.class)),
 workRouter);

 }

 }


But I don't see any place where you use workRouter.

-Endre

 --
  Read the docs: http://akka.io/docs/
  Check the FAQ:
 http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user
 ---
 You received this message because you are subscribed to the Google Groups
 Akka User List group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to akka-user+unsubscr...@googlegroups.com.
 To post to this group, send email to akka-user@googlegroups.com.
 Visit this group at http://groups.google.com/group/akka-user.
 For more options, visit https://groups.google.com/d/optout.




-- 
Akka Team
Typesafe - The software stack for applications that scale
Blog: letitcrash.com
Twitter: @akkateam

-- 
  Read the docs: http://akka.io/docs/
  Check the FAQ: 
 http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups Akka 
User List group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Akka (Java) Competing Consumers

2014-05-02 Thread Manoj Nair
Hi, 

I am trying out a competing event consumer implementation using Akka and 
Camel. Am using Akka 2.3.2 and Camel 5.8.0. I am connecting camel to 
ActiveMQ broker and using a producer to generate messages from other end. 
In the following code EventManager is the master which creates pool of 
consumers and EventProcessor is the message processing actor. 

EventManager.java

import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.camel.component.ActiveMQComponent;
import org.apache.camel.CamelContext;

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UntypedActor;

import akka.camel.Camel;
import akka.camel.CamelExtension;
import akka.japi.Creator;
import akka.routing.RoundRobinPool;

public class EventManager {




private final ActorSystem akkaSystem;

private CamelContext camelContext = null;

private ActorRef workRouter;

public EventManager(ActorSystem system) {
akkaSystem = system;

initialize();
}

public void initialize() {

Camel camel = CamelExtension.get(akkaSystem);

camelContext = camel.context();

ActiveMQComponent activemqComponent = 
ActiveMQComponent.activeMQComponent(tcp://localhost:61616);
activemqComponent.setDeliveryPersistent(false);
camelContext.addComponent(activemq,activemqComponent );


int numOfWorkers = 5;

// distributing the message processing across a pool of 5 actors
ActorRef workRouter =
  akkaSystem.actorOf(new 
RoundRobinPool(numOfWorkers).props(Props.create(EventProcessor.class)), 
workRouter);

}

}

EventProcessor.java

import org.apache.log4j.Logger;

import com.wipro.sif.controller.event.ControllerEvent;

import akka.actor.UntypedActor;
import akka.camel.CamelMessage;
import akka.camel.javaapi.UntypedConsumerActor;

public class EventProcessor extends UntypedConsumerActor{

private static final Logger LOGGER = 
Logger.getLogger(EventProcessor.class);
public EventProcessor() {

}

public void onReceive(Object message) {
if(message instanceof CamelMessage) {
CamelMessage camelMessage = (CamelMessage) message;
String body = camelMessage.getBodyAs(String.class, getCamelContext());
LOGGER.info(Message handled by : +this.getSelf().path().name());

LOGGER.info(Message body: + body);
}


}

public boolean autoAck() {
return true;
}
public String getEndpointUri() {
return activemq:queue:dest;
}

}

The problem I am seeing is that the messages seems to be consumed by a 
single actor and not getting distributed across the pool. Do I need to 
create a separate camel route to distribute ? I would also like to 
distribute the processing across different physical nodes. Appreciate your 
inputs and best practices. 

-- 
  Read the docs: http://akka.io/docs/
  Check the FAQ: 
 http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups Akka 
User List group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.