[akka-user] BalancingPool - ConfigException$BadPath

2015-03-11 Thread sinel
Hi,

In my code, I am creating a pool in the following standard manner:

private lazy val scriptProcessor: ActorRef = 
context.actorOf(BalancingPool(poolSize).props(ScriptProcessor.props()), 
scriptProcessor)

If I use RoundRobinPool or SmallestMailboxPool, my code works fine. 
However, for BalancingPool, I get the following error:

com.typesafe.config.ConfigException$BadPath: path parameter: Invalid path 
'BalancingPool-/scriptBroker/connio-dev$acc315007900463911240$sp/scriptProcessor':
 
Token not allowed in path expression: 'a' ('$' not followed by {, 'a' not 
allowed after '$') (you can double-quote this token if you really want it 
here)

It might be related to issue #13981, but apparently this was fixed and 
closed back in April, 2014. I'm using Scala 2.11.5 and Akka 2.3.9.

Any ideas?

Thanks,

Sinan


-- 
  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] Testing actors expectMsgType[HttpResponse] with matchers gives different results when using should equal or triple equal sign '==='

2015-03-11 Thread Roland Kuhn
Hi Avi,

The authoritative answer should come from the library that gave you the === 
operator, but if my guess is correct that this is ScalaTest then what you are 
seeing is easily explained by the fact that === is just a more type-safe 
version of ==, meaning that it returns a boolean. If you want an assertion then 
use 

a should ===(b)

Regards,

Roland 

Sent from my iPhone

 On 10 Mar 2015, at 08:12, Avi Levi 123...@gmail.com wrote:
 
 Hi,
 I am not sure where is the right place to put this , but after banging my 
 head against the wall trying to figure out why my tests are not working is 
 expected, I thought it's worth sharing.
 I have noticed that my test pass with this assertion 
 expectMsgType[HttpResponse].status === StatusCodes.OK but also with this 
 expectMsgType[HttpResponse].status === StatusCodes.BadRequest pass the test. 
 I have noticed that the triple equality accepts all status codes, however 
 using Should works as expected 
 expectMsgType[HttpResponse].status should equal(StatusCodes.OK)
 
 did I do something wrong or is a bug ?
 
 best 
 Avi
 -- 
  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.


[akka-user] Cluster Sharding works with 2.3.8 but not snapshot of release-2.3?

2015-03-11 Thread Nan Zhu
Hi, all

I'm doing some development based on cluster sharding, 

everything works if I declare the dependency in build.sbt 

However, 

when I:

step 1. remove the dependency in built.sbt 

step 2. checkout release-2.3 in akka's source directory 

step 3. sbt assembly to get 
akka-contrib_2.10.4-2.3-SNAPSHOT-multi-jvm-assembly.jar 

step 4. put akka-contrib_2.10.4-2.3-SNAPSHOT-multi-jvm-assembly.jar to lib/ 
directory in my project and re build my project

step 5. run my program again

I found that *ShardRegion cannot register with ShardCoordinator, *

*I added some code in ClusterSharding.scala and it shows that, 
ShardCoordinator is started (preStart is executed), and never stopped 
(postStop is never executed)*

*ShardRegion always calls register() since it receives Retry message but 
the Register message is never received by ShardCoordinator (the handler of 
the message is never executed and no dead letter is reported)*

Did I do something wrong for compiling project with the self-made jar?

Thanks for any help!

Best,

Nan


 

-- 
  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] Context of event stream elements

2015-03-11 Thread Matthew
I'm a newbie with Akka Streams so please excuse me if the question seems 
stupid.  I have the need to pass some context info along with the events in 
a stream.  For example, I have something like the following (doesn't 
compile - just for illustration):


case class RequestFile(
req: HttpRequest,
fileId: Int,
fileName: String)


case class ResponseFile(
  res: HttpResponse,
  fileId: Int,
  fileName: String)

val connection: Flow[HttpRequest, HttpResponse, Future[OutgoingConnection]] 
=  Http().outgoingConnection(api.mydomain.com)


val downloadFile: Flow[RequestFile, ResponseFile, Unit] =
  Flow[RequestFile]
  .map(_.req)
  .via(connection)
  .map { res = ResponseFile(res, , ) } //here I don't know 
how to reference the original RequestFile to get the fileId and fileName



Has anybody else dealt with this sort of issue?




-- 
  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: Completing RequestContext with a Future ?

2015-03-11 Thread James Mulcahy
Hello,

I’m struggling to understand how I can complete an akka-http RequestContext 
asynchronously, using a future.  Synchronously completion is 
straightforward, e.g…...

val bundleRoutes = {
  (pathPrefix(bundles)  get) {
path(Segment / meta) {
  bundleId = complete {
HttpResponse(entity = Success!)
  }
}
  }
}

But I can’t find what API call I need in order to return a 
Future[HttpResponse].  If I do the simplest change, returning a completed 
future inside complete()…..

val bundleRoutesAsync = {
  (pathPrefix(bundles)  get) {
path(Segment / meta) {
  bundleId = complete {
Future.successful(HttpResponse(entity = Success!))
  }
}
  }
}

…then the build fails with a type error (not necessarily too surprising).

type mismatch;
[error]  found   : scala.concurrent.Future[akka.http.model.HttpResponse]
[error]  required: akka.http.marshalling.ToResponseMarshallable
[error]   Future.successful(HttpResponse(entity = Success!))

I cannot see in the docs[1] what API I should use to achieve this. 
 Googling suggests that historically, with spray, using side-effecting 
calls with onComplete/onFailure was the right approach — but that doesn’t 
seem to be the case anymore. One thought was to return a 
Future[RouteResult] myself, but the RouteResult docs suggest that I 
shouldn’t be doing this.

I wonder if I’m missing an implicit marshaller that’ll handle the 
Future[HttpResponse] responses.

Could someone point me in the right direction here, please?

—James

[1] 
http://doc.akka.io/api/akka-stream-and-http-experimental/1.0-M4/?_ga=1.53285288.1092433602.1423525300#akka.http.server.RequestContext

-- 
  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: Completing RequestContext with a Future ?

2015-03-11 Thread James Mulcahy

Hello,

I’m struggling to understand how I can complete an akka-http RequestContext 
asynchronously, using a future.  Synchronously completion is straightforward, 
e.g…...

val bundleRoutes = {
  (pathPrefix(bundles)  get) {
path(Segment / meta) {
  bundleId = complete {
HttpResponse(entity = Success!)
  }
}
  }
}

But I can’t find what API call I need in order to return a 
Future[HttpResponse].  If I do the simplest change, returning a completed 
future inside complete()…..

val bundleRoutesAsync = {
  (pathPrefix(bundles)  get) {
path(Segment / meta) {
  bundleId = complete {
Future.successful(HttpResponse(entity = Success!))
  }
}
  }
}

…then the build fails with a type error (not necessarily too surprising).

type mismatch;
[error]  found   : scala.concurrent.Future[akka.http.model.HttpResponse]
[error]  required: akka.http.marshalling.ToResponseMarshallable
[error]   Future.successful(HttpResponse(entity = Success!))

I cannot see in the docs[1] what API I should use to achieve this.  Googling 
suggests that historically, with spray, using side-effecting calls with 
onComplete/onFailure was the right approach — but that doesn’t seem to be the 
case anymore. One thought was to return a Future[RouteResult] myself, but the 
RouteResult docs suggest that I shouldn’t be doing this.

I wonder if I’m missing an implicit marshaller that’ll handle the 
Future[HttpResponse] responses.

Could someone point me in the right direction here, please?

—James

[1] 
http://doc.akka.io/api/akka-stream-and-http-experimental/1.0-M4/?_ga=1.53285288.1092433602.1423525300#akka.http.server.RequestContext

-- 
  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: Cluster Sharding works with 2.3.8 but not snapshot of release-2.3?

2015-03-11 Thread Nan Zhu
I also tried the following two ways, still doesn't work

1. publish to local maven repository and add dependency in build.sbt

2. reset the code to the last commit of 2.3.8, compile, 



On Wednesday, March 11, 2015 at 4:34:35 PM UTC-4, Nan Zhu wrote:

 Hi, all

 I'm doing some development based on cluster sharding, 

 everything works if I declare the dependency in build.sbt 

 However, 

 when I:

 step 1. remove the dependency in built.sbt 

 step 2. checkout release-2.3 in akka's source directory 

 step 3. sbt assembly to get 
 akka-contrib_2.10.4-2.3-SNAPSHOT-multi-jvm-assembly.jar 

 step 4. put akka-contrib_2.10.4-2.3-SNAPSHOT-multi-jvm-assembly.jar to 
 lib/ directory in my project and re build my project

 step 5. run my program again

 I found that *ShardRegion cannot register with ShardCoordinator, *

 *I added some code in ClusterSharding.scala and it shows that, 
 ShardCoordinator is started (preStart is executed), and never stopped 
 (postStop is never executed)*

 *ShardRegion always calls register() since it receives Retry message but 
 the Register message is never received by ShardCoordinator (the handler of 
 the message is never executed and no dead letter is reported)*

 Did I do something wrong for compiling project with the self-made jar?

 Thanks for any help!

 Best,

 Nan


  

-- 
  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 - complete with headers

2015-03-11 Thread Giovanni Alberto Caporaletti
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-11 Thread Giovanni Alberto Caporaletti
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-11 Thread Alexey Romanchuk
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 javascript:
  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 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.




 -- 

 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.


[akka-user] Akka Camel websocket client producer doesn't work

2015-03-11 Thread George CGV
Hello everybody,

I just posted a problem I am struggling with on stackoverflow 
http://stackoverflow.com/questions/28982333/akka-camel-websocket-client-producer.
 
I haven't got too many views there and no answer so far, so decided to post 
it over here to people who use Akka the most; maybe someone will be able to 
help me out.

I will copy my stackoverflow post here.

I am trying to communicate with a websocket server using Apache Camel 
AHC-Websocket Component with Akka Camel in Java. In this case, websocket 
endpoint is goint to be a well known websocket public service 
https://www.websocket.org/echo.html.

Using:

   - JDK *8.x*
   - Akka Java API with Akka Camel, Akka Actor and Akka SLF4J *2.3.9*
   - Apache Camel with AHC WS Component *2.14.1*

I followed Akka Camel tutorial for Java located over here 
http://doc.akka.io/docs/akka/2.1.4/java/camel.html.

Short description: Every response received by UntypedProducerActor when I 
make a request returns CamelMessage with body field as null. But when I 
make request via ProducerTemplate I receive correct response.

Long description: I am getting strange behaviour from Akka Camel when I 
make a request and expect a response from the websocket endpoint. When I 
make a request to the endpoint via defined ActorRef, for example like so:

ActorRef wsProducer = 
getContext().actorOf(SimpleProducer.props(ahc-ws:echo.websocket.org));
final Timeout timeout = new Timeout(3, TimeUnit.MINUTES);final FutureObject 
future = Patterns.ask(wsProducer, Please, respond!, timeout);final Object 
result = Await.result(future, timeout.duration());

I clearly see in the logs that Apache Camel websocket endpoint received a 
response:

DEBUG o.a.c.component.ahc.ws.WsEndpoint - received message -- Please, 
respond!

But the result object will be a CamelMessage with body field always set to 
null. The same CamelMessage present in public Object 
onTransformResponse(Object message) method of my SimpleProducer.

However, when I make request via ProducerTemplate like this:

final Camel camel = CamelExtension.get(getContext().system());final 
CamelContext context = camel.context();final ProducerTemplate template = 
camel.template();
Object result = template.requestBody(ahc-ws:echo.websocket.org, Alpha is 
there!);

It works and result will contain correct response body: Alpha is there!.

My SimpleProducer is pretty much the same as in tutorial:

public class SimpleProducer extends UntypedProducerActor {
private final LoggingAdapter LOG = Logging.getLogger(getContext().system(), 
this);

private final String mEndpointUri;

public SimpleProducer(final String serverUrl) {
mEndpointUri = serverUrl;
}

@Override
public String getEndpointUri() {
return mEndpointUri;
}

@Override
public Object onTransformResponse(Object message) {
return super.onTransformOutgoingMessage(message);
}

@Override
public boolean isOneway() {
return false;
}

public static Props props(final String endpointUri) {
return Props.create(new CreatorSimpleProducer() {
private static final long serialVersionUID = 1L;

@Override
public SimpleProducer create() throws Exception {
return new SimpleProducer(endpointUri);
}
});
}}

Maybe somebody had the same issue and can help me out?

-- 
  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-http: Completing RequestContext with a Future ?

2015-03-11 Thread Roland Kuhn
Hi James,

I'm on my phone right now but I think you'll need an implicit execution context 
in scope. That error message should definitely be improved if possible.

Regards,

Roland 

Sent from my iPhone

 On 11 Mar 2015, at 14:24, James Mulcahy ja...@manque.net wrote:
 
 
 Hello,
 
 I’m struggling to understand how I can complete an akka-http RequestContext 
 asynchronously, using a future.  Synchronously completion is straightforward, 
 e.g…...
 
 val bundleRoutes = {
   (pathPrefix(bundles)  get) {
 path(Segment / meta) {
   bundleId = complete {
 HttpResponse(entity = Success!)
   }
 }
   }
 }
 
 But I can’t find what API call I need in order to return a 
 Future[HttpResponse].  If I do the simplest change, returning a completed 
 future inside complete()…..
 
 val bundleRoutesAsync = {
   (pathPrefix(bundles)  get) {
 path(Segment / meta) {
   bundleId = complete {
 Future.successful(HttpResponse(entity = Success!))
   }
 }
   }
 }
 
 …then the build fails with a type error (not necessarily too surprising).
 
 type mismatch;
 [error]  found   : scala.concurrent.Future[akka.http.model.HttpResponse]
 [error]  required: akka.http.marshalling.ToResponseMarshallable
 [error]   Future.successful(HttpResponse(entity = Success!))
 
 I cannot see in the docs[1] what API I should use to achieve this.  Googling 
 suggests that historically, with spray, using side-effecting calls with 
 onComplete/onFailure was the right approach — but that doesn’t seem to be the 
 case anymore. One thought was to return a Future[RouteResult] myself, but the 
 RouteResult docs suggest that I shouldn’t be doing this.
 
 I wonder if I’m missing an implicit marshaller that’ll handle the 
 Future[HttpResponse] responses.
 
 Could someone point me in the right direction here, please?
 
 —James
 
 [1] 
 http://doc.akka.io/api/akka-stream-and-http-experimental/1.0-M4/?_ga=1.53285288.1092433602.1423525300#akka.http.server.RequestContext
 -- 
  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] Again about tell don't ask and use Actor tell instead future

2015-03-11 Thread Richard Rodseth
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, Владимир Морозов greenhos...@gmail.com
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: String, id: String)

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

 trait DAO {
   def loadTaskIds(processorName: String): Future[Seq[TaskId]]

   def loadTaskDetails(id: TaskId): Future[Option[TaskDetails]]

   def deleteTask(id: TaskId): Future[Boolean]

   def markSuccess(id: TaskId): Future[Boolean]
 }

 class Processor(name: String, dao: DAO, implicit val ec: ExecutionContext) {
   def process(): Unit = {
 dao
   .loadTaskIds(name)
   .map(_.map {
   case taskId =
 dao.loadTaskDetails(taskId).flatMap {
   case None =
 delete(taskId)
   case Some(task) if task.status == success =
 delete(taskId)
   case Some(task) =
 doProcess(task).flatMap {
   case true =
 dao.markSuccess(taskId).map {
   case true =
 Some(task)
   case false =
 // log.error(...)
 None
 }
   case false =
 // log.error(...)
 Future.successful(None)
 }
 }
 }).map {
   case processingFutures =
 Future.sequence(processingFutures).map(_.flatten).map {
   case completedTasks =
   // log.info(sProcessing '$name' tasks, complete 
 [${completedTasks.map(_.id).mkString(, )}])
 }
 }
   }

   private def doProcess(task: TaskDetails): Future[Boolean] = ???

   private def delete(taskId: TaskId): Future[Option[TaskDetails]] =
 dao.deleteTask(taskId).map {
   case true =
 None
   case false =
 // log.error(...)
 None
 }
 }


 My question: how I need to change this code for getting 'True' Actor based
 application without using futures or ask pattern.

 PS: I read that I need use only actor tell (!) but I can't understand how
 I can rewrite my logic and DAO as an actor.

 With best regards, Vladimir.

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