Re: [akka-user] Re: akka-http: combine path together

2015-03-12 Thread Jim Hazen
I was confused.  I thought you were looking for something like:

 path(v2.0 / tokens) {
  post {
complete(it works)
  }
} ~
 path(v2.0 / somethingelse) {
  post {
complete(it works)
  }
}

 Otherwise with 
 path(v2.0) {
path(tokens) {

You're matching against path(v2.0) and then further trying to also match 
against path(tokens).  Since a path can't start with both v2.0 and 
tokens at the same time, this always fails.  There are other path 
directives you can use for this type of processing and I think you've 
already discovered some of them.

akka-http is based off of spray concepts.  Spray's documentation is 
currently much better than akka-http.  You should probably start 
here http://spray.io/documentation/1.2.2/spray-routing/ to learn more about 
what routing directives are available and how to compose them together. 
 All directives may not exist yet in akka-http, but the sections on the 
Path DSL should be valid.

-- 
  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-http] an empty response body is send with the text/plain content type

2015-03-12 Thread Yann Simon
Hi,

by using
complete(HttpResponse(status = NoContent))
or
complete(NoContent)

the HTTP response contains the header:
Content-Type: text/plain; charset=UTF-8

If I understand the code correctly, HttpEntity.Empty should not send this
content type:
val Empty: Strict = Strict(ContentTypes.NoContentType, data =
ByteString.empty)
val NoContentType = ContentType(MediaTypes.NoMediaType)

Can somebody explains me where does this header come from?

Cheers, Yann

-- 
  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] Re: getting scala-zeromq (and/or akka-zeromq) to work with c++ program

2015-03-12 Thread ankit master
Found the solution, just in case anyone gets in the same spot as I was 
earlier, the problem is with the incompatibility between zmq 2.2 and zmq 
4.0.4, although zmq website advertises zmq latest version stating it is 
backwards compatible it is NOT. when I stepped down my zmq version to 3.2.5 
my scala and c++ zmq programs started talking. 



On Monday, March 9, 2015 at 3:50:54 PM UTC-7, ankit master wrote:

 Hello, 

 I am trying to get c++(publisher) to my scala(subscriber ) with little 
 luck, I tried using both akka-zeromq and scala-zeromq to get this working 
 with little luck. however, my program *does work* with *scala being the 
 publisher and c++ being the subscriber (but not other way around)*, can 
 anyone please help me figure out what I am doing wrong here !! 

 The following code will not work, I dont get any messages over on scala 
 side, will be very grateful of any help here. 

 / Scala Code  , zmq version 2.2 

 import akka.actor._
 import org.zeromq.ZMQ
 import org.zeromq.ZMQ._

 object ZMQWithoutAkkaExtensionApp extends App {
   val numberOfMessages = 10

   val system = ActorSystem(zmq)
   val subscriber = system.actorOf(Props[Sub])
   subscriber ! start
 }


 class Sub extends Actor {
   var contextZMQ: ZMQ.Context = null
   var subscriberSocket: ZMQ.Socket = null

   override def preStart = {
 contextZMQ = ZMQ.context(1)
 subscriberSocket = contextZMQ.socket(ZMQ.SUB)
 subscriberSocket.connect(tcp://localhost:1234)
 subscriberSocket.subscribe(.getBytes())
 Thread.sleep(1000)
   }

   def receive = {
 case msg = handleMessages
   }

   private def handleMessages = {
 while (true) {
   println(-)
   val request = subscriberSocket.recv(0)
   println(srequest : $request)
   val data = new String(request)
   println(sdata: $data )
 }
   }
 }



  C++ Code , zmq version 4.0.4


 #include zmq.hpp
 #include string
 #include iostream
 #include windows.h
 #include thread

 using namespace std;
 void Pub()
 {
 cout   Running Pub   endl;

 zmq::context_t context(1);
 zmq::socket_t publisher(context, ZMQ_PUB);
 publisher.bind(tcp://*:1234);

 Sleep(4000);
 cout   awake again   endl;

 int cc = 0; 
 while (1) {
 //  Write two messages, each with an envelope and content
 string msg =  hello ;
 zmq::message_t req(5);
 memcpy((void *)req.data(), World, 5);

 publisher.send(req);
  cout  cc++  endl; 

 Sleep(1000);
 }
 }

 int main()
 {

 Pub();

 return 0;
 }


 Thank you 
 Sincerely, 
 AVM


-- 
  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] Re: Problems using a Remote Actor

2015-03-12 Thread Sandro Martini
Hi Jim, thanks for the help ...

Have you followed all of the instructions for interacting with remote 
actors here: http://doc.akka.io/docs/akka/2.3.9/scala/remoting.html ?
I follow this because I'm using the Java version of the API:
http://doc.akka.io/docs/akka/2.2.5/java/remoting.html
and them the updated (more/better info)
http://doc.akka.io/docs/akka/2.3.9/java/remoting.html

Note that I have the same behavior from 3 different pc (Windows and Linux) 
and with different patch levels on JDK 7 (but all recent), so it's 
something related to code ...

Just for info, my project is made with Gradle 2.3, so to try it its' enough 
to checkout with git, and run it with Gradle (if already installed, or its 
wrapper will download it), and all dependencies are downloaded at first 
run, I made it to make it simple for anyone to run/try it.
 


 From the error it appears to me that:
 1. You are attempting to create a remote actor from a peer

yes, but I didn't read for problems with it in documentation ... 

2. This peer isn't able to properly interact with [akka.tcp://
 RemoteActorSystem-Client@127.0.0.1:55003]

yes but from the error/warning message it's not clear what is the real 
problem ... 


 Are you using a Remote or Clustered ActorRefProviders on both nodes?  

no, I'm using normal  akka.remote.RemoteActorRefProvider

Is your remote transport properly configured to run on those ports?  Is it 
 starting properly? Is your networking configured to allow access to those 
 ports (software firewalls on a node have burned me in the past).

yes, I see that the related port is open, with an OS diagnostic tool
 

 Does the RemoteActorSystem-Client AS exist on that port, or is some other 
 AS running there?

nothing special is running
 

 There's a lot to look at, but it ought to work once everything is wired 
 properly.

yes, but all seems ok, so really I think it's a problem in my code
 

 Maybe look for a working example (from Activator) and then adapt the 
 working thing to your needs?

maybe this is a good option, but my sample here is even to try to use Akka 
from a (little) different point of view (and tools like Gradle) ... maybe 
even Akka documentation could be improved, at least to better explain some 
pitfalls on exposing actors with remoting  ... just as a suggestion for 
Akka team.
One of goals for my test project is even to share/improve some knowledge on 
using Akka from other tools (mainly the Groovy/Gradle/Grails stack) with 
others :-) .


Thanks a lot for the help.
Sandro

-- 
  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] Re: Akka http - complete with headers

2015-03-12 Thread Giovanni Alberto Caporaletti
oh! That was it! thanks ;) 

I'll remember to check if they add it to the documentation once it's 
released. 


Cheers
G
On Thursday, 12 March 2015 10:00:46 UTC, Mark Hatton wrote:

 Completing a route with a Tuple3[StatusCode, Seq[HttpHeader], T]  doesn't 
 seem to work for me.


 Ensure your headers collection is an instance of immutable.Seq.  E.g.:

 import collection.immutable._

 complete( (OK, Seq(`Cache-Control`(`no-cache`)), responseEntity) )


 Works for me.

 Mark

  
 On Thursday, March 12, 2015 at 12:18:28 AM UTC, Giovanni Alberto 
 Caporaletti wrote:

 This is what I came up with (I have another question below):

 def onSuccessHead(magnet: OnStreamSuccessHeadMagnet): Directive[magnet.Out] 
 = {
   magnet.directive
 }

 trait OnStreamSuccessHeadMagnet {
   type Out
   def directive: Directive[Out]
 }

 object OnStreamSuccessHeadMagnet {
   import akka.http.server.directives.FutureDirectives._

   implicit def apply[T](s: Source[T, _])(implicit mat: 
 ActorFlowMaterializer, tupler: Tupler[T]) = {
 new OnStreamSuccessHeadMagnet {
   type Out = tupler.Out
   val directive = 
 onSuccess(s.runWith(Sink.head(SourceMarshallerHeadSink)): Future[T])
 }
   }

 }


 and the route:

 onSuccessHead(userService.createUser(req)) { newUser =
   respondWithHeader(Location(s/$v1/$user/${newUser.id})) {
 complete(Created - newUser)
   }
 }



 By the way, is there a way of extracting constant paths? e.g. my path 
 is path(v1 / user) but I don't want to have separate constants for v1 
 and user and something like path(some / path) { (some, path) = ...} 
 doesn't work. In other words, how do you do reverse routing in spray/akka 
 http?

 Thanks
 G


 On Thursday, 12 March 2015 00:10:24 UTC, Giovanni Alberto Caporaletti 
 wrote:

 Hi,
 Completing a route with a Tuple3[StatusCode, Seq[HttpHeader], T] 
  doesn't seem to work for me. My json4s marshaller serializes the whole 
 tuple as an object. Tuple2[StatusCode, T] works instead.
 Are there any plans to implement it?

 What's the best way to add headers to a response anyway? In my case the 
 header depends on a future (or, well, on a materialization of a stream). 


 Thank you

 Cheers
 G



-- 
  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] Re: Akka http - complete with headers

2015-03-12 Thread Mark Hatton


 Completing a route with a Tuple3[StatusCode, Seq[HttpHeader], T]  doesn't 
 seem to work for me.


Ensure your headers collection is an instance of immutable.Seq.  E.g.:

import collection.immutable._

complete( (OK, Seq(`Cache-Control`(`no-cache`)), responseEntity) )


Works for me.

Mark

 
On Thursday, March 12, 2015 at 12:18:28 AM UTC, Giovanni Alberto 
Caporaletti wrote:

 This is what I came up with (I have another question below):

 def onSuccessHead(magnet: OnStreamSuccessHeadMagnet): Directive[magnet.Out] = 
 {
   magnet.directive
 }

 trait OnStreamSuccessHeadMagnet {
   type Out
   def directive: Directive[Out]
 }

 object OnStreamSuccessHeadMagnet {
   import akka.http.server.directives.FutureDirectives._

   implicit def apply[T](s: Source[T, _])(implicit mat: ActorFlowMaterializer, 
 tupler: Tupler[T]) = {
 new OnStreamSuccessHeadMagnet {
   type Out = tupler.Out
   val directive = 
 onSuccess(s.runWith(Sink.head(SourceMarshallerHeadSink)): Future[T])
 }
   }

 }


 and the route:

 onSuccessHead(userService.createUser(req)) { newUser =
   respondWithHeader(Location(s/$v1/$user/${newUser.id})) {
 complete(Created - newUser)
   }
 }



 By the way, is there a way of extracting constant paths? e.g. my path is 
 path(v1 / user) but I don't want to have separate constants for v1 and 
 user and something like path(some / path) { (some, path) = ...} 
 doesn't work. In other words, how do you do reverse routing in spray/akka 
 http?

 Thanks
 G


 On Thursday, 12 March 2015 00:10:24 UTC, Giovanni Alberto Caporaletti 
 wrote:

 Hi,
 Completing a route with a Tuple3[StatusCode, Seq[HttpHeader], T]  doesn't 
 seem to work for me. My json4s marshaller serializes the whole tuple as an 
 object. Tuple2[StatusCode, T] works instead.
 Are there any plans to implement it?

 What's the best way to add headers to a response anyway? In my case the 
 header depends on a future (or, well, on a materialization of a stream). 


 Thank you

 Cheers
 G



-- 
  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 Streams 1.0 release date?

2015-03-12 Thread Jacobus Reyneke
Hi Ronald and Patrik,

Are the release cycles of Akka Streams and Akka HTTP roughly the same.

I'm starting a new REST-only service and I'm not sure if I should use Spray 
again, or start this project on Akka-Http. The product I'm developing will 
be in production in about 2 months, so timing is a little tricky.

Best regards,
Jacobus

On Wednesday, 11 March 2015 19:38:44 UTC+2, rkuhn wrote:

 Hi Alexey,

 we cannot make any hard promises on API compatibility at this point, but 
 we expect things to calm down considerably now. There is one thing that we 
 have not yet implemented which might require the addition of a type 
 parameter to FlowGraph.Builder, but as I said this list is possibly not 
 exhaustive.

 Regards,

 Roland

 11 mar 2015 kl. 03:55 skrev Alexey Romanchuk alexey.r...@gmail.com 
 javascript::

 Patrik, is it any fundamental problems in API right now? Do you plan to 
 break backward compatibility before 1.0?

 вторник, 10 марта 2015 г., 16:18:35 UTC+6 пользователь Patrik Nordwall 
 написал:

 We will release 1.0 as soon as possible, but not earlier. We will 
 continue to release frequent milestones until we reach release candidate 
 quality. We don't have an estimate of how long that will take, but I guess 
 it is in the magnitude of a few months.

 Regards,
 Patrik

 On Mon, Mar 9, 2015 at 6:48 PM, Ali Beyad alib...@gmail.com wrote:

 Dear All,

 Is there any projected timeframe for releasing version 1.0?  After the 
 release of 1.0-M4, I wasn't sure how close Akka was to the official 1.0 
 release of streams.

 Thank you,

 Ali Beyad

 -- 
  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.




 -- 

 Patrik Nordwall
 Typesafe http://typesafe.com/ -  Reactive apps on the JVM
 Twitter: @patriknw

 [image: Scala Days] http://event.scaladays.org/scaladays-sanfran-2015

  
 -- 
  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.




 *Dr. Roland Kuhn*
 *Akka Tech Lead*
 Typesafe http://typesafe.com/ – Reactive apps on the JVM.
 twitter: @rolandkuhn
 http://twitter.com/#!/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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Stop shard region gracefully

2015-03-12 Thread Hannes Stockner
Hello,

how is it possible to stop a shard region and all the shards located on the 
same node gracefully?

Thanks a lot
Hannes

-- 
  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] Stop shard region gracefully

2015-03-12 Thread Hannes Stockner
Hello,

I am trying to stop my current Cluster Sharding application gracefully.
So far I couldn't find a way to stop a shard region and all the shards 
located on the same node gracefully.

What would be a good way to achieve that?

Thanks a lot
Hannes

-- 
  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] SslTlsCipherActor: Getting access to MultiStreamInputProcessor$SubstreamOnError

2015-03-12 Thread Edward Sargisson
Hi,
I'm trying to setup a client using TLS over TCP to connect to a server. The 
client is using Akka Streams 1.0-M4.

At the moment I'm stymied:
1. After a series of debug messages about handshake, wrap and unwrap, the 
SslTlsCipherActor writes a debug log of 
### HS NEED_TASK
Running delegated task sun.security.ssl.Handshaker$DelegatedTask@38dcaf04

2. Then, after about 5s I get: 
Message [akka.stream.impl.MultiStreamInputProcessor$SubstreamOnError] from 
Actor[akka://chirp-dbus-notifier/deadLetters] to 
Actor[akka://chirp-dbus-notifier/user/ssl-client-1#1884597281] was not 
delivered

Presumably that SubstreamOnError contains the exception that would give me 
a clue about what's failing. However, it's not being delivered to my actor 
and I can't include it in my actor anyway because it's private.

So:
1. How do I get access to that exception?
2. Is there a Akka Stream 1.0-M4 example of using TLS over TCP?

Many thanks in advance,
Edward

-- 
  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] Stop shard region gracefully

2015-03-12 Thread Dragisa Krsmanovic
I am interested in that too.

So far, I've seen that leaving cluster gracefully with cluster.leave(...),
won't cause shard manager to automatically rebalance actors. Instead, it
relies on rebalance-interval settings.

On Thu, Mar 12, 2015 at 9:41 AM, Hannes Stockner hannes.stock...@gmail.com
wrote:

 Hello,

 I am trying to stop my current Cluster Sharding application gracefully.
 So far I couldn't find a way to stop a shard region and all the shards
 located on the same node gracefully.

 What would be a good way to achieve that?

 Thanks a lot
 Hannes

 --
  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] Stop shard region gracefully

2015-03-12 Thread Patrik Nordwall
I think you are looking for #16050
https://github.com/akka/akka/issues/16050.

I have actually a prototype of that ready so it will be available in Akka
2.4 (or some earlier snapshot/milestone).

Cheers,
Patrik

On Thu, Mar 12, 2015 at 11:28 AM, Dragisa Krsmanovic dragis...@gmail.com
wrote:

 I am interested in that too.

 So far, I've seen that leaving cluster gracefully with cluster.leave(...),
 won't cause shard manager to automatically rebalance actors. Instead, it
 relies on rebalance-interval settings.

 On Thu, Mar 12, 2015 at 9:41 AM, Hannes Stockner 
 hannes.stock...@gmail.com wrote:

 Hello,

 I am trying to stop my current Cluster Sharding application gracefully.
 So far I couldn't find a way to stop a shard region and all the shards
 located on the same node gracefully.

 What would be a good way to achieve that?

 Thanks a lot
 Hannes

 --
  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.




-- 

Patrik Nordwall
Typesafe http://typesafe.com/ -  Reactive apps on the JVM
Twitter: @patriknw

[image: Scala Days] http://event.scaladays.org/scaladays-sanfran-2015

-- 
  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] Again about tell don't ask and use Actor tell instead future

2015-03-12 Thread Владимир Морозов
Hi, *rrodseth*

thank you for link, I read it and try to re-write my code from Futures to 
actor 'Tell', but at now example DAO are not async (but I think at now it's 
not a problem):

import akka.actor._

import scala.concurrent.duration._

object ExampleActorBoot extends App {
  val system = ActorSystem(ExampleActorBoot)

  val dao = system.actorOf(Props[DaoActor], dao)
  val processor = system.actorOf(Props(new ProcessorActor(test, dao)), 
processor)

  processor ! ProcessorActor.Process
}

case class TaskId(processorName: String, id: String)

case class TaskDetails(id: TaskId, status: String, json: String)

object DaoActor {

  sealed trait DaoActorMessage {
def receiver: ActorRef
  }

  case class LoadTaskIds(processorName: String, receiver: ActorRef) extends 
DaoActorMessage

  case class LoadTaskDetails(id: TaskId, receiver: ActorRef) extends 
DaoActorMessage

  case class DeleteTask(id: TaskId, receiver: ActorRef) extends DaoActorMessage

  case class MarkSuccess(id: TaskId, receiver: ActorRef) extends DaoActorMessage

}

class DaoActor extends Actor with ActorLogging {

  import com.episodetracker.boot.DaoActor._

  override def receive = {
case LoadTaskIds(processorName, receiver) =
  val result = 1 to 4 map {
case i =
  TaskId(processorName, i.toString)
  }

  receiver ! result
case LoadTaskDetails(id, receiver) =
  val result = TaskDetails(id, pending, JSON)
  receiver ! result
case DeleteTask(id, receiver) =
  receiver ! true
case MarkSuccess(id, receiver) =
  receiver ! true
  }
}

object ProcessorActor {

  sealed trait ProcessorActorMessage

  case object Process extends ProcessorActorMessage

  private case class TaskComplete(id: TaskId, isSuccess: Boolean) extends 
ProcessorActorMessage

  private case class ProcessingComplete(result: Seq[(TaskId, Boolean)]) extends 
ProcessorActorMessage

}

class ProcessorActor(name: String, dao: ActorRef) extends Actor with 
ActorLogging {

  import com.episodetracker.boot.ProcessorActor._

  override def receive = {
case Process =
  dao ! DaoActor.LoadTaskIds(name, context.actorOf(Props(new 
TasksProcessorResultActor(
case ProcessingComplete(result) =
  sender() ! PoisonPill
  log.info(sProcessing complete with results [$result])
case unknown =
  log.error(sUnknown message [$unknown])
  }

  val emptyResult = Seq[(TaskId, Boolean)]()

  class TasksProcessorResultActor extends Actor {
context.setReceiveTimeout(3 seconds)

override def receive = default(0, emptyResult)

def default(awaitResults: Int, completedTasks: Seq[(TaskId, Boolean)]): 
Receive = {
  case tasks: Seq[TaskId] =
tasks.foreach {
  case task =
context.actorOf(Props(new TaskProcessorActor(task)))
}
context become default(tasks.size, emptyResult)
  case TaskComplete(id, isSuccess) =
val results = completedTasks :+ ((id, isSuccess))

if (results.size == awaitResults) {
  context.parent ! ProcessingComplete(results)
} else {
  context become default(awaitResults, results)
}
  case unknown =
log.error(sUnknown message [$unknown])
}
  }

  class TaskProcessorActor(taskId: TaskId) extends Actor with ActorLogging {
override def receive = default

dao ! DaoActor.LoadTaskDetails(taskId, self)

def default: Receive = {
  case taskDetails: TaskDetails =
taskDetails.status match {
  case success =
dao ! DaoActor.DeleteTask(taskDetails.id, self)
context.become(waitDaoResponse)
  case _ =
//TODO: do some processing
dao ! DaoActor.MarkSuccess(taskDetails.id, self)
context.become(waitDaoResponse)
}
  case unknown =
log.error(sUnknown message [$unknown])
}

def waitDaoResponse: Receive = {
  case true =
context.parent ! TaskComplete(taskId, true)
  case false =
context.parent ! TaskComplete(taskId, false)
}
  }

}


I think it's not perfect and if code in //TODO: do some processing  need 
some DAO call, actor code with become go to hell.

What in second sample can be corrected or improved?

With best regards, Vladimir.

среда, 11 марта 2015 г., 17:14:21 UTC+3 пользователь rrodseth написал:

 Hi Vladimir

 I have had good luck with using per-request actors as in the Net-a-porter 
 activator template, and a replyTo:ActorRef in the messages sent to my 
 DbActor (which still talks to a DAO)

 Some more detail in this thread

 http://qnalist.com/questions/5581605/using-tell-or-ask-with-akka-persistence-and-rest

 On Tue, Mar 10, 2015 at 2:55 PM, Владимир Морозов green...@gmail.com 
 javascript: wrote:

 Hi All,

 this question about design, for example now I have some process that load 
 task list and try process each task, it looks like this:

 import scala.concurrent.{ExecutionContext, Future}


 case class TaskId(processorName: 

Re: [akka-user] Re: Problems using a Remote Actor

2015-03-12 Thread Sandro Martini
A quick update,
a notable difference in my sources is that I call the actorSelection(...) 
but from my client actor system, and not from another actor (in the usual 
way contect.actorSelection(...) find in many documents):

ActorSelection selection = systemClient.actorSelection(remoteBasePath + 
remoteActorName);

could be this ?
If yes, are there some good reason to not do the call in this way ?

Should I open an issue in Akka (to fix it, or at least to clarify this in 
docs) ?

Sorry for all these questions, but I'm really trying to better understand 
(and simplify if possible) this ...


Thanks,
Sandro


Il giorno giovedì 12 marzo 2015 11:07:00 UTC+1, Sandro Martini ha scritto:

 Hi Jim, thanks for the help ...

 Have you followed all of the instructions for interacting with remote 
 actors here: http://doc.akka.io/docs/akka/2.3.9/scala/remoting.html ?
 I follow this because I'm using the Java version of the API:
 http://doc.akka.io/docs/akka/2.2.5/java/remoting.html
 and them the updated (more/better info)
 http://doc.akka.io/docs/akka/2.3.9/java/remoting.html

 Note that I have the same behavior from 3 different pc (Windows and Linux) 
 and with different patch levels on JDK 7 (but all recent), so it's 
 something related to code ...

 Just for info, my project is made with Gradle 2.3, so to try it its' 
 enough to checkout with git, and run it with Gradle (if already installed, 
 or its wrapper will download it), and all dependencies are downloaded at 
 first run, I made it to make it simple for anyone to run/try it.
  


 From the error it appears to me that:
 1. You are attempting to create a remote actor from a peer

 yes, but I didn't read for problems with it in documentation ... 

 2. This peer isn't able to properly interact with [akka.tcp://
 RemoteActorSystem-Client@127.0.0.1:55003]

 yes but from the error/warning message it's not clear what is the real 
 problem ... 


 Are you using a Remote or Clustered ActorRefProviders on both nodes?  

 no, I'm using normal  akka.remote.RemoteActorRefProvider

 Is your remote transport properly configured to run on those ports?  Is it 
 starting properly? Is your networking configured to allow access to those 
 ports (software firewalls on a node have burned me in the past).

 yes, I see that the related port is open, with an OS diagnostic tool
  

 Does the RemoteActorSystem-Client AS exist on that port, or is some other 
 AS running there?

 nothing special is running
  

 There's a lot to look at, but it ought to work once everything is wired 
 properly.

 yes, but all seems ok, so really I think it's a problem in my code
  

 Maybe look for a working example (from Activator) and then adapt the 
 working thing to your needs?

 maybe this is a good option, but my sample here is even to try to use Akka 
 from a (little) different point of view (and tools like Gradle) ... maybe 
 even Akka documentation could be improved, at least to better explain some 
 pitfalls on exposing actors with remoting  ... just as a suggestion for 
 Akka team.
 One of goals for my test project is even to share/improve some knowledge 
 on using Akka from other tools (mainly the Groovy/Gradle/Grails stack) with 
 others :-) .


 Thanks a lot for the help.
 Sandro



-- 
  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] Cluster: Multiple leaders / ReachableMember not propagated / ...?

2015-03-12 Thread michaels


On Tuesday, March 10, 2015 at 4:17:10 PM UTC+1, Patrik Nordwall wrote:

 What was puzzling me was:
 Cluster Node [akka.tcp://...Node4...] - Marking node(s) as REACHABLE 
 [Member(address = akka.tcp://Node1..., status = Up)]

 but looking at the code revealed that this is only an notification that 
 Node4 thinks that Node1 is reachable again. The ReachableMember event is 
 fired when all thinks it is reachable again, and that will not happen until 
 Node3 is back in business or removed.


So...while being still in this status
- Node 1: MemberStatus=Up, Leader = 1 / Unreachable = Node 3
- Node 2: MemberStatus=Up, Leader = 2 / Unreachable = Node 1, 3
- Node 4: MemberStatus=Up, Leader = 2 / Unreachable = Node 1, 3

...is it a problem for Node 2 and Node 3 if Node 1 has the cluster 
singleton?

I mean, from the state above, i suppose Node 1 will be able handle 
application tasks (which require cluster singleton actions) perfectly.

But what about Node 2 and Node 4? Will they use the cluster singleton of 
Node 1, even if they have Node 1 in their Unreachable List?

Thanks,

Michael


-- 
  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] Cluster: Multiple leaders / ReachableMember not propagated / ...?

2015-03-12 Thread Patrik Nordwall
On Tue, Mar 10, 2015 at 4:38 PM, michaels michael.schr...@atos.net wrote:



 On Tuesday, March 10, 2015 at 4:17:10 PM UTC+1, Patrik Nordwall wrote:

 What was puzzling me was:
 Cluster Node [akka.tcp://...Node4...] - Marking node(s) as REACHABLE
 [Member(address = akka.tcp://Node1..., status = Up)]

 but looking at the code revealed that this is only an notification that
 Node4 thinks that Node1 is reachable again. The ReachableMember event is
 fired when all thinks it is reachable again, and that will not happen until
 Node3 is back in business or removed.


 So...while being still in this status
 - Node 1: MemberStatus=Up, Leader = 1 / Unreachable = Node 3
 - Node 2: MemberStatus=Up, Leader = 2 / Unreachable = Node 1, 3
 - Node 4: MemberStatus=Up, Leader = 2 / Unreachable = Node 1, 3

 ...is it a problem for Node 2 and Node 3 if Node 1 has the cluster
 singleton?

 I mean, from the state above, i suppose Node 1 will be able handle
 application tasks (which require cluster singleton actions) perfectly.

 But what about Node 2 and Node 4? Will they use the cluster singleton of
 Node 1, even if they have Node 1 in their Unreachable List?


Yes, cluster singleton decisions are not based on unreachability
information at all.
/Patrik



 Thanks,

 Michael


  --
  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.




-- 

Patrik Nordwall
Typesafe http://typesafe.com/ -  Reactive apps on the JVM
Twitter: @patriknw

[image: Scala Days] http://event.scaladays.org/scaladays-sanfran-2015

-- 
  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.