Re: [akka-user] Akka Persistence - Views with multiple processors

2015-04-14 Thread Patrik Nordwall
Hi Andrew,

I think your reasoning is correct. A way to implement the de-duping (if db
operations are not idempotent by themselves) is to save the sequence number
in the external db together with the writes. When starting up, before
replaying, you load the latest seq num from the db and then you know that
you can ignore all replay events with lower seq num.

/Patrik

On Wed, Apr 8, 2015 at 6:34 PM, Andrew Easter andrew.eas...@gmail.com
wrote:

 Okay, I've been reading more about PersistentView.

 I'm thinking I could achieve what I'm referring to here through the use of
 view snapshots?

 i.e.

 1) Periodically save snapshots every N hours/minutes/seconds
 2) Save snapshot on shutdown of the PersistentView so that when it's
 recreated, it only starts consuming from last processed seq num

 If the view writes to the db and, for whatever reason, crashes before
 persisting a snapshot that incorporates some handled seq nums, it's simply
 the case that updates to the db need to be idempotent, or some method of
 de-duping needs to be in place?

 On a related note, if the last seq number is relied upon, what happens in
 the case a write to the db fails? Of course, the write could be retried a
 few times, but, if it's still not successful following a max number of
 retries, I guess one would have to give up on it and log the error
 somewhere such that the problem is at least identified?






 On Wednesday, 8 April 2015 16:24:38 UTC+1, Andrew Easter wrote:

 Hi Patrik.

 Sorry to drag this up so long after it was posted, but I have a question
 about it...


 Let's say we have a User aggregate root with some profile information
 that can be updated. The user is represented by a User
 EventsourcedProcessor actor, which is sharded. On the query side we want to
 be able to search users by first and last name, i.e. we want to store all
 users in a relational database table on the query side.



 The User actor persist FirstNameChanged, and inside the persist block it
 sends a Persistent(FirstNameChanged) message to the AllUsers Processor. On
 the query side we have a AllUsersView connected to that processor. When
 AllUsersView receives FirstNameChanged it updates the db table.



 To handle lost messages between User and AllUsers you might want to send
 an acknowledgement from AllUsers to User, and have a retry mechanism in
 User. I would implement that myself in User, but PersistentChannel might be
 an alternative.


 I'm a little confused about how this solution avoids writing every event
 from AllUsers to the db table on every recovery of AllUsersView. In your
 original post, you contrasted this approach with another, in which you said:

 It must keep track of how far it has replayed/stored in db, i.e. seqNr
 must be stored in the db.


 The implication is that the first approach (mentioned above) would _not_
 need to keep track of the seq number in the db - i.e. that would only be
 required in the second approach. However, I can't see how this would avoid,
 during recovery of the AllUsersView, re-writing every event to the database
 unless referring to a seq number stored in the db.

 Am I missing something?

 Thanks,
 Andrew


 On Thursday, 29 January 2015 08:30:09 UTC, Patrik Nordwall wrote:



 On Thu, Jan 22, 2015 at 9:01 PM, Yann Simon yann.s...@gmail.com wrote:

 Hi Patrick,

 Le dimanche 20 avril 2014 16:59:22 UTC+2, Patrik Nordwall a écrit :




 On Sun, Apr 20, 2014 at 2:47 PM, Olger Warnier ol...@spectare.nl
 wrote:

 Hi Patrick,

 Sounds like an interesting approach, storing some meta-data at the
 view may help to check / show the reliability of the system.

 At this moment the events are sent to a processor per node that
 publishes the event (distributed pub sub)


 That sounds good, as well.


 When you talk about view, that's the akka-persistence view ?


 Yes, persistence.View and persistence.Processor


 So more or less, the sub processors could send messages to the View
 and when there is a Persist() around it, it will be stored.


 I'm not sure I understand what you mean here. Let me clarify my
 proposal with an example. Let's say we have a User aggregate root with 
 some
 profile information that can be updated. The user is represented by a User
 EventsourcedProcessor actor, which is sharded. On the query side we want 
 to
 be able to search users by first and last name, i.e. we want to store all
 users in a relational database table on the query side.

 The User actor persist FirstNameChanged, and inside the persist block
 it sends a Persistent(FirstNameChanged) message to the AllUsers Processor.
 On the query side we have a AllUsersView connected to that processor. When
 AllUsersView receives FirstNameChanged it updates the db table.

 To handle lost messages between User and AllUsers you might want to
 send an acknowledgement from AllUsers to User, and have a retry mechanism
 in User. I would implement that myself in User, but PersistentChannel 
 might
 be an alternative.


 Let's say the 

Re: [akka-user] Re: [akka-stream] Props Source ignoring dispatcher

2015-04-14 Thread Patrik Nordwall
This is about to be fixed https://github.com/akka/akka/pull/17175.


A possible workaround in 1.0-M5 is that you create the KafkaConsumerActor
yourself and use a Source(ActorSubscriber(kafkaConsumerActorRef)).

/Patrik

On Tue, Apr 14, 2015 at 6:42 AM, Jeff jknight12...@gmail.com wrote:

 This is using 1.0-M5


 On Monday, April 13, 2015 at 9:32:38 PM UTC-7, Jeff wrote:

 I am creating an ActorPublisher to encapsulate a kafka consumer. I am
 trying to bulkhead the actor behind a custom dispatcher (since the kafka
 consumer is blocking) with the following code:

 val in = Source[Array[Byte]](KafkaConsumerActor.props(consumer.
 createMessageStreamsByTopic(topic).head).withDispatcher(
 kafka-consumer-dispatcher))

 However, when I set a breakpoint in the receive method and inspect the
 context, the dispatcher is set to default-dispatcher


 https://lh3.googleusercontent.com/-GSsCrdUDXtc/VSyYFsKunFI/BPM/OQ8Q9tdqGbA/s1600/Screen%2BShot%2B2015-04-13%2Bat%2B9.28.27%2BPM.png

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

-- 
  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] How to get info about a router send message to which routee?

2015-04-14 Thread zyj177484
Hi,
I have set a Akka cluster using 9 server and each server running 18 actor.
I have config a router:

actor {
  provider = akka.cluster.ClusterActorRefProvider
  deployment {
/controller/producer/workerRouter {
  router = random-group
  routees.paths = [/user/sbecitacube/worker1, 
/user/sbecitacube/worker2, /user/sbecitacube/worker3, 
/user/sbecitacube/worker4, /user/sbecitacube/worker5, 
/user/sbecitacube/worker6, /user/sbecitacube/worker7, 
/user/sbecitacube/worker8, /user/sbecitacube/worker9, 
/user/sbecitacube/worker10, /user/sbecitacube/worker11, 
/user/sbecitacube/worker12, /user/sbecitacube/worker13, 
/user/sbecitacube/worker14, /user/sbecitacube/worker15, 
/user/sbecitacube/worker16, /user/sbecitacube/worker17, 
/user/sbecitacube/worker18]
  cluster {
max-nr-of-instances-per-node = 18
min-nr-of-instances-per-node = 18
enabled = on
allow-local-routees = on
  }
}
  }
}


For PD: I want to know how to get info about a router send message to which 
routee?
I need to log a router send message to which routee(Host/IP and actor).

Thanks,
Zhang, Yangjie(Jeff)
email: zyj177...@126.com

-- 
  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] 2.4-SNAPSHOT Did bind-hostname/bind-port functionality change?

2015-04-14 Thread tigerfoot
Hello,

I had a working demo of Akka remoting working in a Docker container.  I ran 
my server in Docker and was able to communicate with it from an external 
program.  My application.conf looked like this:

akka {
loglevel = ERROR
stdout-loglevel = ERROR
loggers = [akka.event.slf4j.Slf4jLogger]
actor {
provider = akka.remote.RemoteActorRefProvider
}
remote {
enabled-transports = [akka.remote.netty.tcp]
netty.tcp {
# Internal addr
bind-hostname = localhost # also tried 127.0.0.1
bind-port = 2551

# External Docker addr
hostname = 172.16.240.141
port = 9100
}
}
}

Boxed up I run my container like this (to map ports)--the web port mapping 
works fine:

docker run -it -p 9100:2551 -p 9101:8080 --name dexp localhost:5000/root

My client tries to connect to it like this:

val c = ConfigFactory parseString akka {

  actor {

provider = akka.remote.RemoteActorRefProvider

  }

  remote {

enabled-transports = [akka.remote.netty.tcp]

netty.tcp {

  hostname = localhost

  port = 5151

}

  }

}



  val sys = ActorSystem( boom, c )

  val actor = sys.actorSelection(
akka.tcp://dockerexp@172.16.240.141:9100/user/dockerexp)

  println(Actor: +actor)

  implicit val timo = Timeout(5.seconds)

  try { 

println( Await.result( (actor ? hey).asInstanceOf[Future[String]], 15.
seconds) )

  } finally {

println(Dying...)

Thread.sleep(5000)

sys.shutdown()

  }

This isn't working anymore--just times out and dies.  It did work several 
months ago when 2.4-SNAPSHOT was first available.  Am I doing something 
wrong?

Thanks,
Greg

-- 
  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] ReadPrefered in FlexiMerge (akka-streams)

2015-04-14 Thread Roland Kuhn
The bug (yes, it is one) and the fix are here 
https://github.com/akka/akka/pull/17188. Thanks for the very good report, 
Johannes!

Regards,

Roland

 13 apr 2015 kl. 19:20 skrev Viktor Klang viktor.kl...@gmail.com:
 
 Is if(input eq p.priority) also true?
 
 On Mon, Apr 13, 2015 at 7:11 PM, Johannes Plapp johannes.pl...@gmail.com 
 mailto:johannes.pl...@gmail.com wrote:
 Hi,
 
 While implementing a FlexiMerge we stumbled on the following issue:
 
 override def initialState =
   State[T](ReadPreferred(p.priority, p.second)) {
 (ctx, input, element) =
   if(input == p.priority).. // always true
   ctx.emit(element)
   SameState
   }
 
 Even if ReadPrefered returns an element from the second input, the returned 
 input always equals the first one (p.priority).
 
 Is this intended behaviour? I also submitted a test covering this issue: 
 https://github.com/akka/akka/issues/17157 
 https://github.com/akka/akka/issues/17157
 
 Thanks, 
 Johannes Plapp
 
 -- 
  Read the docs: http://akka.io/docs/ http://akka.io/docs/
  Check the FAQ: 
  http://doc.akka.io/docs/akka/current/additional/faq.html 
  http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user 
  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 
 mailto:akka-user+unsubscr...@googlegroups.com.
 To post to this group, send email to akka-user@googlegroups.com 
 mailto:akka-user@googlegroups.com.
 Visit this group at http://groups.google.com/group/akka-user 
 http://groups.google.com/group/akka-user.
 For more options, visit https://groups.google.com/d/optout 
 https://groups.google.com/d/optout.
 
 
 
 -- 
 Cheers,
 √
 
 -- 
  Read the docs: http://akka.io/docs/ http://akka.io/docs/
  Check the FAQ: 
  http://doc.akka.io/docs/akka/current/additional/faq.html 
  http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user 
  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 
 mailto:akka-user+unsubscr...@googlegroups.com.
 To post to this group, send email to akka-user@googlegroups.com 
 mailto:akka-user@googlegroups.com.
 Visit this group at http://groups.google.com/group/akka-user 
 http://groups.google.com/group/akka-user.
 For more options, visit https://groups.google.com/d/optout 
 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] Overriding default configuration

2015-04-14 Thread Tal Pressman
Hi,

I am working on an application that has an application.conf file (under 
src/main/resources) with some application-specific configuration. When I 
build (package) the application, the application.conf gets copied into the 
JAR file and Akka loads it as expected (using ConfigFactory.load()).

But now I want to override the default configuration with one provided in a 
file. I tried placing another application.conf file on my classpath (same 
directory my JAR is in), but it didn't work. I tried renaming the default 
configuration file to reference.conf, but that didn't seem to work either.

I also tried using the config.file property, but then it requires the file 
be present, and doesn't load the default provided configuration. Any 
suggestions?

Thanks,
Tal

-- 
  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-ClusterSharding 2.3.7/2.3.9] After ClusterShardFailover ShardAllocation gets lost

2015-04-14 Thread Wolfgang Friedl
Hi everyone!

We do have the following setup. 4 Nodes of the Cluster 2 Seed-Nodes.

I startup all four nodes and wait until the cluster has formed. Afterwards 
I put some load on our cluster to ensure that the ClusterShard creates 
shards  on all four Nodes.

Now I remove the node which hosts the cluster-shard  via leave (using 
cluster jmx - leave). In the logs I observe that the node does terminate 
all ShardRegions and store them

DEBUG [DispatcherV2-akka.actor.default-dispatcher-2] 
[a.contrib.pattern.ShardCoordinator] ShardRegion terminated: 
[Actor[akka.tcp://DispatcherV2@127.0.0.1:3554/user/sharding/DispatcherShard#966892993]]
DEBUG [DispatcherV2-akka.actor.default-dispatcher-26] 
[a.contrib.pattern.ShardCoordinator] ShardRegion terminated: 
[Actor[akka.tcp://DispatcherV2@127.0.0.1:3554/user/sharding/DispatcherShard#-281584836]]
DEBUG [DispatcherV2-akka.actor.default-dispatcher-2] 
[a.contrib.pattern.ShardCoordinator] ShardRegion terminated: 
[Actor[akka.tcp://DispatcherV2@127.0.0.1:3555/user/sharding/DispatcherShard#1026653998]]
DEBUG [DispatcherV2-akka.actor.default-dispatcher-50] 
[a.contrib.pattern.ShardCoordinator] ShardRegion terminated: 
[Actor[akka.tcp://DispatcherV2@127.0.0.1:3556/user/sharding/DispatcherShard#1399093271]]

The node which does take over the ShardCooridnator recovers this 
information via Akka-Persitence

 [a.contrib.pattern.ShardCoordinator] receiveRecover 
ShardHomeAllocated(29,Actor[akka://DispatcherV2/user/sharding/DispatcherShard#-281584836])
 [a.contrib.pattern.ShardCoordinator] receiveRecover 
ShardHomeAllocated(25,Actor[akka.tcp://DispatcherV2@127.0.0.1:3555/user/sharding/DispatcherShard#1026653998])
 [a.contrib.pattern.ShardCoordinator] receiveRecover 
ShardHomeAllocated(49,Actor[akka.tcp://DispatcherV2@127.0.0.1:3556/user/sharding/DispatcherShard#1399093271])
 [a.contrib.pattern.ShardCoordinator] receiveRecover 
ShardRegionTerminated(Actor[akka://DispatcherV2/user/sharding/DispatcherShard#-281584836])
 [a.contrib.pattern.ShardCoordinator] receiveRecover 
ShardRegionTerminated(Actor[akka.tcp://DispatcherV2@127.0.0.1:3555/user/sharding/DispatcherShard#1026653998])
 [a.contrib.pattern.ShardCoordinator] receiveRecover 
ShardRegionTerminated(Actor[akka.tcp://DispatcherV2@127.0.0.1:3556/user/sharding/DispatcherShard#1399093271])

which leads to the problem that the node thinks on the Nodes (127.0.0.1:3556, 
and 127.0.0.1:3555) no shards are running. If I now send a create-request 
(with an shard-key of an running actor hosted by one of the running nodes) 
the ShardCoordinator does create a new Actor with the same shard-key on a 
different host (of course not always sometimes by luck it is the same). 

So I do have  two actors with the same shard-key running in the cluster, 
which is of course a problem. For me it seems the problem is that during 
the leave-prodecure all ShardRegion gets Terminated, but frankly speaking I 
do not know how this is happening. 

Regards

Wolfgang

-- 
  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] 2.4-SNAPSHOT Did bind-hostname/bind-port functionality change?

2015-04-14 Thread Viktor Klang
Hi Greg,

have you verified that the configuration is applied to the application?

On Tue, Apr 14, 2015 at 10:13 AM, tigerfoot gzol...@gmail.com wrote:

 Hello,

 I had a working demo of Akka remoting working in a Docker container.  I
 ran my server in Docker and was able to communicate with it from an
 external program.  My application.conf looked like this:

 akka {
 loglevel = ERROR
 stdout-loglevel = ERROR
 loggers = [akka.event.slf4j.Slf4jLogger]
 actor {
 provider = akka.remote.RemoteActorRefProvider
 }
 remote {
 enabled-transports = [akka.remote.netty.tcp]
 netty.tcp {
 # Internal addr
 bind-hostname = localhost # also tried 127.0.0.1
 bind-port = 2551

 # External Docker addr
 hostname = 172.16.240.141
 port = 9100
 }
 }
 }

 Boxed up I run my container like this (to map ports)--the web port mapping
 works fine:

 docker run -it -p 9100:2551 -p 9101:8080 --name dexp localhost:5000/root

 My client tries to connect to it like this:

 val c = ConfigFactory parseString akka {

   actor {

 provider = akka.remote.RemoteActorRefProvider

   }

   remote {

 enabled-transports = [akka.remote.netty.tcp]

 netty.tcp {

   hostname = localhost

   port = 5151

 }

   }

 }



   val sys = ActorSystem( boom, c )

   val actor = sys.actorSelection(akka.tcp://
 dockerexp@172.16.240.141:9100/user/dockerexp)

   println(Actor: +actor)

   implicit val timo = Timeout(5.seconds)

   try {

 println( Await.result( (actor ? hey).asInstanceOf[Future[String]],
 15.seconds) )

   } finally {

 println(Dying...)

 Thread.sleep(5000)

 sys.shutdown()

   }

 This isn't working anymore--just times out and dies.  It did work several
 months ago when 2.4-SNAPSHOT was first available.  Am I doing something
 wrong?

 Thanks,
 Greg

 --
  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] StreamTcp exceptions handling

2015-04-14 Thread Илья Ненахов
Do I need to dynamicaly change source to close connection? If I do it in
client updateSink Success case there is no effect.

2015-04-10 11:59 GMT+03:00 Akka Team akka.offic...@gmail.com:

 Hi,

 On Tue, Apr 7, 2015 at 3:57 PM, zergood zergoodso...@gmail.com wrote:

 Is there an api for closing client connection?


 The API is there, but it is implicit. By completing the input side of
 the TCP Flow the connections write side is automatically closed. For
 example:

   Source.empty.via(connectionFlow)

 will immediately close the writing side of the connection (half-close)
 since the empty source immediately completes.

 -Endre



 вторник, 7 апреля 2015 г., 16:40:46 UTC+3 пользователь Akka Team написал:



 On Tue, Apr 7, 2015 at 3:38 PM, zergood zergoo...@gmail.com wrote:

 Here is my client code:
   def downloadUpdate(address: InetSocketAddress, outputFilePath:String
 )(implicit system: ActorSystem):Unit = {
 import scala.concurrent.duration._
 implicit val actorStreamMaterializer = ActorFlowMaterializer()
 val connection = StreamTcp(system).outgoingConnection(address,
   connectTimeout = 20.seconds, idleTimeout = 20.seconds)


 val updateSink = OnCompleteSink[Unit] {
   case Success(_) =
   case Failure(ex) =
 }


 val download = FlowGraph { implicit b =
   import akka.stream.scaladsl.FlowGraphImplicits._
   val in = Source(Promise().future)
   val process = Flow[ByteString].map(chunk = {
 receiveDataStreamChunk(chunk, outputFilePath)
   })


   in ~ connection.flow ~ process ~ updateSink
 }


 download.run()
   }


   def receiveDataStreamChunk(chunk: ByteString, outputFilePath:String):
 Unit

 receiveDataStreamChunk method simply write chunks to file.

 As I understand you correctly client needs to close connection when all
 data is received. In my scenario only server knows if data is sended
 completly or not. May be I don't understand you but why is TCP connection
 not closed by server automatically when everything is sended?


 It does, but TCP has half-close, so it does not terminate the
 server-side flow until the client closes its half of the TCP connection.

 -Endre


 If there is an exception in the receiveDataStreamChunk method, does it
 lead to closing client TCP connection? Or do I need to close it in
 updateSink Failure case?

 вторник, 7 апреля 2015 г., 15:00:39 UTC+3 пользователь drewhk написал:



 On Tue, Apr 7, 2015 at 1:47 PM, zergood zergoo...@gmail.com wrote:

 Thank you for your answer.

 But If I use onCompleteSink after connection flow, future will not be
 completed successfully however data will be downloaded by client.


 The only reason for that could be that the client does not close the
 connection after it downloaded the data you have sent. However, connection
 close might have nothing to do whether the data has been successfully
 received or not.


 If client is failed while downloading there are still no exceptions
 on server side.

  Could you provide me some links from documentation about exception
 handling in StreamTcp?


 There is nothing special about StreamTcp, it works like any other
 Flow. The onError signal only travels downwards.


 Do I need onCompleteSink in my case at all?

 updateSource ~ connection.flow ~ OnCompleteSink[ByteString]


 This OnCompleteSink will provide a future that will finish with
 success if the connection has been normally close, or failing otherwise. 
 It
 can say nothing about whether the user successfully downloaded anything or
 not by default unless if the client can be assumed to only close the
 connection once everything has been processed. How does your client look
 like?

 -Endre




 вторник, 7 апреля 2015 г., 14:16:13 UTC+3 пользователь Akka Team
 написал:

 Hi,

 The connection flow will publish the errors, but you feed them to a
 BackholeSink. Also, your OnCompleteSink is probably at the wrong place 
 --
 it will not tell you anything about whether the TCP connection have sent
 everything fine or not. As such, you will close the binding before you 
 have
 sent everything through TCP.

 -Endre

 On Mon, Apr 6, 2015 at 3:23 PM, zergood zergoo...@gmail.com wrote:

 Hello!

 My server side:

   def update: Iterator[ByteString]

   lazy val binding = StreamTcp(system).bind(address, idleTimeout =
 20.seconds)

   def start(): Future[Unit] = {
 val firstCompleted = Promise[Unit]()
 val foreachConnection = ForeachSink[IncomingConnection] {
   connection =
 val handleConnection = FlowGraph { implicit b =
   import akka.stream.scaladsl.FlowGraphImplicits._
   val updateSource = Source[ByteString](() = update)
   val broadcast = Broadcast[ByteString]

   updateSource ~ broadcast
   broadcast ~ connection.flow ~ BlackholeSink
   broadcast ~ OnCompleteSink[ByteString] { res =
 firstCompleted.complete(res)
   }
 }

  handleConnection.run()
 }


 val 

[akka-user] akka-http is there an example of showing how to integrate with servlet container?

2015-04-14 Thread Jas
is there an example showing how to integrate servlet container with 
akka-http? i'm currently using spray with serlvet 
with 
https://github.com/spray/spray/blob/master/spray-servlet/src/main/scala/spray/servlet/Servlet30ConnectorServlet.scala
 
and was hoping to find an example showing how to perform this with 
akka-http..

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-http is there an example of showing how to integrate with servlet container?

2015-04-14 Thread Roland Kuhn
Hi Tomer,

the servlet container way of running things completely negates all the benefits 
that Akka HTTP would give you, so there is no point in supporting this 
scenario—spray-servlet will not be ported to Akka HTTP.

Sorry for the bad news,

Roland

 14 apr 2015 kl. 15:45 skrev Jas tomer...@gmail.com:
 
 is there an example showing how to integrate servlet container with 
 akka-http? i'm currently using spray with serlvet with 
 https://github.com/spray/spray/blob/master/spray-servlet/src/main/scala/spray/servlet/Servlet30ConnectorServlet.scala
  and was hoping to find an example showing how to perform this with 
 akka-http..
 
 thanks
 
 -- 
  Read the docs: http://akka.io/docs/ http://akka.io/docs/
  Check the FAQ: 
  http://doc.akka.io/docs/akka/current/additional/faq.html 
  http://doc.akka.io/docs/akka/current/additional/faq.html
  Search the archives: https://groups.google.com/group/akka-user 
  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 
 mailto:akka-user+unsubscr...@googlegroups.com.
 To post to this group, send email to akka-user@googlegroups.com 
 mailto:akka-user@googlegroups.com.
 Visit this group at http://groups.google.com/group/akka-user 
 http://groups.google.com/group/akka-user.
 For more options, visit https://groups.google.com/d/optout 
 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.


Re: [akka-user] akka-http is there an example of showing how to integrate with servlet container?

2015-04-14 Thread Jas
thank you! sounds like a good option considering my system is already 
integrated with tomcat!

On Tuesday, April 14, 2015 at 5:55:10 PM UTC+3, √ wrote:

 One integration you can do easily is to have a ServletContextListener that 
 creates the Akka Http server endpoint when loaded and stops it on unload.

 On Tue, Apr 14, 2015 at 3:53 PM, Roland Kuhn goo...@rkuhn.info 
 javascript: wrote:

 Hi Tomer,

 the servlet container way of running things completely negates all the 
 benefits that Akka HTTP would give you, so there is no point in supporting 
 this scenario—spray-servlet will not be ported to Akka HTTP.

 Sorry for the bad news,

 Roland

 14 apr 2015 kl. 15:45 skrev Jas tome...@gmail.com javascript::

 is there an example showing how to integrate servlet container with 
 akka-http? i'm currently using spray with serlvet with 
 https://github.com/spray/spray/blob/master/spray-servlet/src/main/scala/spray/servlet/Servlet30ConnectorServlet.scala
  
 and was hoping to find an example showing how to perform this with 
 akka-http..

 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+...@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+...@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-ClusterSharding 2.3.7/2.3.9] After ClusterShardFailover ShardAllocation gets lost

2015-04-14 Thread Patrik Nordwall
Ah, this is a bug. The shard region actor is actually not stopped when the
member is removed from the cluster. The terminated that you see on the
other side comes from death watch, which is triggered when a cluster member
is removed.

Please create an issue https://github.com/akka/akka/issues/new, and I
will fix it tomorrow.

Thanks,
Patrik

On Tue, Apr 14, 2015 at 11:59 AM, Wolfgang Friedl 
wolfgang.fri...@hotmail.com wrote:

 Hi everyone!

 We do have the following setup. 4 Nodes of the Cluster 2 Seed-Nodes.

 I startup all four nodes and wait until the cluster has formed. Afterwards
 I put some load on our cluster to ensure that the ClusterShard creates
 shards  on all four Nodes.

 Now I remove the node which hosts the cluster-shard  via leave (using
 cluster jmx - leave). In the logs I observe that the node does terminate
 all ShardRegions and store them

 DEBUG [DispatcherV2-akka.actor.default-dispatcher-2]
 [a.contrib.pattern.ShardCoordinator] ShardRegion terminated:
 [Actor[akka.tcp://
 DispatcherV2@127.0.0.1:3554/user/sharding/DispatcherShard#966892993]]
 DEBUG [DispatcherV2-akka.actor.default-dispatcher-26]
 [a.contrib.pattern.ShardCoordinator] ShardRegion terminated:
 [Actor[akka.tcp://
 DispatcherV2@127.0.0.1:3554/user/sharding/DispatcherShard#-281584836]]
 DEBUG [DispatcherV2-akka.actor.default-dispatcher-2]
 [a.contrib.pattern.ShardCoordinator] ShardRegion terminated:
 [Actor[akka.tcp://
 DispatcherV2@127.0.0.1:3555/user/sharding/DispatcherShard#1026653998]]
 DEBUG [DispatcherV2-akka.actor.default-dispatcher-50]
 [a.contrib.pattern.ShardCoordinator] ShardRegion terminated:
 [Actor[akka.tcp://
 DispatcherV2@127.0.0.1:3556/user/sharding/DispatcherShard#1399093271]]

 The node which does take over the ShardCooridnator recovers this
 information via Akka-Persitence

  [a.contrib.pattern.ShardCoordinator] receiveRecover
 ShardHomeAllocated(29,Actor[akka://DispatcherV2/user/sharding/DispatcherShard#-281584836])
  [a.contrib.pattern.ShardCoordinator] receiveRecover
 ShardHomeAllocated(25,Actor[akka.tcp://
 DispatcherV2@127.0.0.1:3555/user/sharding/DispatcherShard#1026653998])
  [a.contrib.pattern.ShardCoordinator] receiveRecover
 ShardHomeAllocated(49,Actor[akka.tcp://
 DispatcherV2@127.0.0.1:3556/user/sharding/DispatcherShard#1399093271])
  [a.contrib.pattern.ShardCoordinator] receiveRecover
 ShardRegionTerminated(Actor[akka://DispatcherV2/user/sharding/DispatcherShard#-281584836])
  [a.contrib.pattern.ShardCoordinator] receiveRecover
 ShardRegionTerminated(Actor[akka.tcp://
 DispatcherV2@127.0.0.1:3555/user/sharding/DispatcherShard#1026653998])
  [a.contrib.pattern.ShardCoordinator] receiveRecover
 ShardRegionTerminated(Actor[akka.tcp://
 DispatcherV2@127.0.0.1:3556/user/sharding/DispatcherShard#1399093271])

 which leads to the problem that the node thinks on the Nodes (
 127.0.0.1:3556, and 127.0.0.1:3555) no shards are running. If I now send
 a create-request (with an shard-key of an running actor hosted by one of
 the running nodes) the ShardCoordinator does create a new Actor with the
 same shard-key on a different host (of course not always sometimes by luck
 it is the same).

 So I do have  two actors with the same shard-key running in the cluster,
 which is of course a problem. For me it seems the problem is that during
 the leave-prodecure all ShardRegion gets Terminated, but frankly speaking I
 do not know how this is happening.

 Regards

 Wolfgang

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

-- 
  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 is there an example of showing how to integrate with servlet container?

2015-04-14 Thread Viktor Klang
One integration you can do easily is to have a ServletContextListener that
creates the Akka Http server endpoint when loaded and stops it on unload.

On Tue, Apr 14, 2015 at 3:53 PM, Roland Kuhn goo...@rkuhn.info wrote:

 Hi Tomer,

 the servlet container way of running things completely negates all the
 benefits that Akka HTTP would give you, so there is no point in supporting
 this scenario—spray-servlet will not be ported to Akka HTTP.

 Sorry for the bad news,

 Roland

 14 apr 2015 kl. 15:45 skrev Jas tomer...@gmail.com:

 is there an example showing how to integrate servlet container with
 akka-http? i'm currently using spray with serlvet with
 https://github.com/spray/spray/blob/master/spray-servlet/src/main/scala/spray/servlet/Servlet30ConnectorServlet.scala
 and was hoping to find an example showing how to perform this with
 akka-http..

 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.




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




-- 
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] Overriding default configuration

2015-04-14 Thread Adam
First of all, regardless of inclusion, you need your build to exclude this 
application.conf file from jars. There's not much point for a configuration 
file that can't be easily modified. It should instead be in a folder (e.g. 
./conf) that is added to your classpath.

Then, you can either add your own file with an include directive for 
application.conf and load your file as the main one via the system property, or 
you can have your build rename the original application.conf (e.g. to 
some-lib.conf) and name your file application.conf and again use the include 
directive with the name you picked.

-- 
  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] 500 ISE for Client Side Error Bug Report

2015-04-14 Thread Kevin Meredith
There's a Github issue, titled, 500 ISE for Client Side Error 
-  https://github.com/akka/akka/issues/17187.

For the below error, I grepped for 

cc2 [ERROR] [04/13/2015 16:01:07.698] 
[cloud-controller-akka.actor.default-dispatcher-27] 
[ActorSystem(cloud-controller)] Internal server error, sending 500 response
cc2 java.lang.IllegalArgumentException: requirement failed: Requests with this 
method must have an empty entity
cc2 at scala.Predef$.require(Predef.scala:219)

$ cd akka 
$ grep -r method must have an empty entity * | grep -vi test | grep -vi spec
$

Where does this code exist? 

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.


[akka-user] Number of actors

2015-04-14 Thread Adam
Hi,

First of all, actors are very lightweight and you can have many of them, while 
an ActorSystem is heavyweight and you should not have many of that (typically 
you'd have one).

As for the pattern you describe - it all depends on the fine details, but if I 
had to implement a service that needs to get a set of details and was permitted 
(and required) to return partial results depending on some timeout, I'd have 
one actor to manage the request, sending the smaller sub requests and I'd 
indeed use the scheduler to cut this off if tge timeout expires.

It might be useful for you to take a look at the aggregator pattern referenced 
from the docs. It has a lot in common with this.

-- 
  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: ReadPrefered in FlexiMerge (akka-streams)

2015-04-14 Thread Johannes Plapp
Thanks a lot for the quick response!

Best regards,
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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Custom Fan In Junction for Akka Stream

2015-04-14 Thread Oliver Winks
I'm using the new Akka Stream library and I'm trying to create a custom 
merge junction, similar to the Zip junction but one that can take any 
number of inputs. However, I can't figure out how to do this. I've followed 
the documentation online and I think I'm close but keep getting this error:

[error] Exception in thread main java.lang.IllegalArgumentException: 
requirement failed: The input port [FanIn.] is not part of the underlying 
graph.


Here is a copy of my code for the custom junction:

class MergePorts(_init: Init[Frame] = Name(Merge)) extends FanInShape[
Frame](_init) {


  val inputs = ListBuffer[Inlet[Frame]]()


  def input = {
val port = newInlet[Frame]()
inputs :+ port
port
  }


  protected override def construct(i: Init[Frame]) = new MergePorts(i)
}


class MergeFrames extends FlexiMerge[Frame, MergePorts](new MergePorts, 
OperationAttributes.name(MergeFrames)) {
  import FlexiMerge._


  override def createMergeLogic(port: PortT) = new MergeLogic[Frame] {
override def initialState: State[_] = State(ReadAll(port.inputs:_*)) 
{ (ctx, _, inputs) =
  val frames = port.inputs.map( in = inputs.get(in) ).flatten


  // Do some merging...


  // Emit result of the merge


  SameState
}
  }
}


I think the problem is to do with the `input` function returning a new 
`Inlet` every call.

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