rayroestenburg / akka-in-action Goto Github PK
View Code? Open in Web Editor NEWAccompanying source code for akka in action
Home Page: https://www.manning.com/books/akka-in-action
License: MIT License
Accompanying source code for akka in action
Home Page: https://www.manning.com/books/akka-in-action
License: MIT License
I was following the instructions in the book and failed in the very beginning. I cloned the Git-Repo to local and tried to start the seed nodes.
Following command was given to the console:
sbt -DHOST=127.0.0.1 -DPORT=2551
I tried it as root and as user (w/o root priviliges), ending up getting different error messages:
As root i got the follwoing:
[error] bad symbolic reference. A signature in SbtMultiJvm.class refers to type AutoPlugin [error] in package sbt which is not available. [error] It may be completely missing from the current classpath, or the version on [error] the classpath might be incompatible with the version used when compiling SbtMultiJvm.class. [error] one error found [error] (compile:compile) Compilation failed
As user i got this:
[error] (*:update) sbt.ResolveException: unresolved dependency: org.scala-lang#scala-library;2.10.4: configuration not found in org.scala-lang#scala-library;2.10.4: 'master(compile)'. Missing configuration: 'compile'. It was required from org.scalactic#scalactic_2.10;2.2.1 compile [error] unresolved dependency: org.scala-lang#scala-reflect;2.10.4: configuration not found in org.scala-lang#scala-reflect;2.10.4: 'master(compile)'. Missing configuration: 'compile'. It was required from org.scalactic#scalactic_2.10;2.2.1 compile
Any ideas what is going wrong?
Using what I think is the current code from GitHub, I encounter some problems building the sample code for chapter 14:
jerryk@poopsmith .../co/akka-in-action/chapter-persistence]$ sbt
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128M; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0
[info] Loading global plugins from /Users/jerryk/.sbt/0.13/plugins
[info] Loading project definition from /Users/jerryk/co/akka-in-action/chapter-persistence/project
[info] Set current project to persistence (in build file:/Users/jerryk/co/akka-in-action/chapter-persistence/)
compile
[info] Compiling 19 Scala sources to /Users/jerryk/co/akka-in-action/chapter-persistence/target/scala-2.11/classes...
*[error] /Users/jerryk/co/akka-in-action/chapter-persistence/src/main/scala/aia/persistence/Serializers.scala:91: not found: value removedEventFormat
[error] JsArray(removedId, removedEventFormat.write(e))
[error] ^
[error] /Users/jerryk/co/akka-in-action/chapter-persistence/src/main/scala/aia/persistence/Serializers.scala:105: not found: value removedEventFormat
[error] removedEventFormat.read(jsEvent)
[error] ^
[error] two errors found
error Compilation failed
[error] Total time: 6 s, completed May 10, 2016 12:55:30 AM
*
Is the stuff as currently checked into GitHub known to exhibit this problem or have I somehow got something out of date or otherwise messed up?
Hi! I'm following along the code in chapter 2, and when I sbt run
or use Heroku's foreman
, I can't see Slf4jEventHandler started
. I forked the code from here directly.
Hi @RayRoestenburg I've started the book yesterday and I find it great. Great work. In chapter-up-and-running, template build.sbt, we still have a dependence for spray-json are there some stuff we still don't have in akka-http-spray-json-experimental? And if that so should we have back the spray-repo in dependecy resolution? Thanks π
sbt.ResolveException: unresolved dependency: com.eed3si9n#sbt-assembly;0.13.0: not found
unresolved dependency: com.typesafe.sbt#sbt-native-packager;1.0.0: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:313)
at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:191)
at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:168)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:156)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:156)
at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:133)
at sbt.IvySbt.sbt$IvySbt$$action$1(Ivy.scala:57)
at sbt.IvySbt$$anon$4.call(Ivy.scala:65)
at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:93)
at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:78)
at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:97)
at xsbt.boot.Using$.withResource(Using.scala:10)
at xsbt.boot.Using$.apply(Using.scala:9)
at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:58)
at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:48)
at xsbt.boot.Locks$.apply0(Locks.scala:31)
at xsbt.boot.Locks$.apply(Locks.scala:28)
at sbt.IvySbt.withDefaultLogger(Ivy.scala:65)
at sbt.IvySbt.withIvy(Ivy.scala:128)
at sbt.IvySbt.withIvy(Ivy.scala:125)
at sbt.IvySbt$Module.withModule(Ivy.scala:156)
at sbt.IvyActions$.updateEither(IvyActions.scala:168)
at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1439)
at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1435)
at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$90.apply(Defaults.scala:1470)
at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$90.apply(Defaults.scala:1468)
at sbt.Tracked$$anonfun$lastOutput$1.apply(Tracked.scala:37)
at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1473)
at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1467)
at sbt.Tracked$$anonfun$inputChanged$1.apply(Tracked.scala:60)
at sbt.Classpaths$.cachedUpdate(Defaults.scala:1490)
at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1417)
at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1369)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
RemoteBoxOfficeForwarder.scala:42
log.info("Actor $actorRef terminated.")
Looks like s
before msg has been forgotten:
log.info(s"Actor $actorRef terminated.")
Ray,
Since most people going through these exercises will not be familiar with the libraires used such as akka and spray, i think the underscore imports make it harder to understand the code.
I see classes pop up but i do not know where they are coming from. For example in RestInterface extends ... with HttpServiceActor, only after googling did i find out that HttpServiceActor is part of spray.
I guess i could switch to another editor that shows me where these classes come from. However i really like my emacs!
Hi,
I started reading your book and trying out the examples, but I get an error building the first example:
saschas-mbp:chapter2 saschamoellering$ sbt assembly
error: error while loading CharSequence, class file '/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/rt.jar(java/lang/CharSequence.class)' is broken
(bad constant pool tag 18 at byte 10)
Hi,
After running command "sbt assembly" for "chapter-up-and-running", I am getting following error:
downloading http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/test-agent/0.13.7/jars/test-agent.jar ...
[SUCCESSFUL ] org.scala-sbt#test-agent;0.13.7!test-agent.jar (1784ms)
downloading http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/apply-macro/0.13.7/jars/apply-macro.jar ...
[SUCCESSFUL ] org.scala-sbt#apply-macro;0.13.7!apply-macro.jar (2823ms)
:: retrieving :: org.scala-sbt#boot-app
confs: [default]
51 artifacts copied, 0 already retrieved (15709kB/890ms)
java.lang.IllegalArgumentException: URI has an authority component
at java.io.File.(File.java:423)
at sbt.Classpaths$.sbt$Classpaths$$bootRepository(Defaults.scala:1699)
at sbt.Classpaths$$anonfun$appRepositories$1.apply(Defaults.scala:1670)
at sbt.Classpaths$$anonfun$appRepositories$1.apply(Defaults.scala:1670)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:34)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
at scala.collection.AbstractTraversable.map(Traversable.scala:105)
at sbt.Classpaths$.appRepositories(Defaults.scala:1670)
at sbt.Classpaths$$anonfun$41.apply(Defaults.scala:1065)
at sbt.Classpaths$$anonfun$41.apply(Defaults.scala:1065)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.EvaluateSettings$MixedNode.evaluate0(INode.scala:175)
at sbt.EvaluateSettings$INode.evaluate(INode.scala:135)
at sbt.EvaluateSettings$$anonfun$sbt$EvaluateSettings$$submitEvaluate$1.apply$mcV$sp(INode.scala:69)
at sbt.EvaluateSettings.sbt$EvaluateSettings$$run0(INode.scala:78)
at sbt.EvaluateSettings$$anon$3.run(INode.scala:74)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[error] java.lang.IllegalArgumentException: URI has an authority component
[error] Use 'last' for the full log.
Please can someone help me here.
OS: Windows 7 64 bit
sbt launcher version 0.13.7
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Regards,
Arun
I followed the instructions in section 2.3, and everything works well until I attempt the command in Listing 2.29. For whatever reason, as shown below, the sbt example you gave is being detected as a Play app (default v 1.3.1). Even if I try to use a scala build pack (using heroku buildpacks:set heroku/scala
), I get a Push rejected, failed to detect set buildpack heroku/scala error. I don't have time to debug this, and would like to know if you have a solution?
git push heroku master
Compressing objects: 100% (1074/1074), done.
Writing objects: 100% (2585/2585), 384.80 KiB | 0 bytes/s, done.
Total 2585 (delta 875), reused 2585 (delta 875)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Play! app detected
remote: -----> Installing OpenJDK 1.6... done
remote: -----> WARNING: Play! version not specified in dependencies.yml. Default version: 1.3.1 being used....
remote: -----> Installing Play! 1.3.1.....
remote: -----> done
remote: -----> Building Play! application...
remote: ~ _ _
remote: ~ _ __ | | __ _ _ _| |
remote: ~ | '_ \| |/ _' | || |_|
remote: ~ | __/|_|\____|\__ (_)
remote: ~ |_| |__/
remote: ~
remote: ~ play! 1.3.1, https://www.playframework.com
remote: ~
remote: 1.3.1
remote: Building Play! application at directory ./
remote: Resolving dependencies: .play/play dependencies ./ --forProd --forceCopy --silent -Duser.home=/tmp/build_2b9abc1199029835e52cc9f7fcd096ed 2>&1
remote: ~ !! /tmp/build_2b9abc1199029835e52cc9f7fcd096ed/conf/dependencies.yml does not exist
remote: ! Failed to build Play! application
remote: ! Cleared Play! framework from cache
remote:
remote: ! Push rejected, failed to compile Play! app
remote:
remote: Verifying deploy....
remote:
remote: ! Push rejected to fierce-falls-1349.
remote:
To https://git.heroku.com/fierce-falls-1349.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/fierce-falls-1349.git'
Note that I am running everything on a MAC OS X Yosemite (10.10.5). I installed the heroku toolbelt from the heroku website, and sbt clean compile stage
goes through with no problems. In addition, I could create a heroku app using the example here (i.e. git push heroku master
for this example ran without problems).
heroku --version
gives the following output:
heroku-toolbelt/3.42.25 (x86_64-darwin10.8.0) ruby/1.9.3
heroku-cli/4.27.9-cce0260 (amd64-darwin) go1.5.2
=== Installed Plugins
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
Sending the very first http messages always gets ignored. Seems like its stuck in identify state. Sending the first message (which will get ignored) seems to force it to move to identified state. All subsequent http messages then are accepted / handled.
Im not sure why (still learning). can be fixed with stash() and unstashAll() but sure this is not best way.
In the "chapter-remoting" module, I upgraded akka to 2.6.19, scala to 2.13.10, and scalatest to 3.2.12. The higher version of akka will make some adjustments to some conf, I can run the example after modification.
Modify example:
Old:
akka {
loglevel = DEBUG
stdout-loglevel = WARNING
loggers = ["akka.event.slf4j.Slf4jLogger"]
actor {
provider = "akka.remote.RemoteActorRefProvider"
}
remote {
enabled-transports = ["akka.remote.netty.tcp"]
netty.tcp {
hostname = "0.0.0.0"
port = 2551
}
}
}
New Content
akka {
loglevel = DEBUG
stdout-loglevel = DEBUG
loggers = ["akka.event.slf4j.Slf4jLogger"]
actor {
provider = remote
allow-java-serialization = on
}
remote {
use-unsafe-remote-features-outside-cluster = true
artery {
enabled = on
transport = tcp
canonical {
hostname = "0.0.0.0"
port = 2551
}
bind {
hostname = "0.0.0.0"
port = 2551
}
}
}
}
This is just an example, but there are other places
So I thought I would submit pr to reduce the cost of learning for newcomers, but it would have the side effect that the code in akka in action would be inconsistent with the repository.
I want to hear your advice and look forward to your reply.
The book has a snippet for explaining using Futures inside Actors. Any chance the full source of that is available to be posted here?
Thanks :)
Hey @RayRoestenburg - I've been working on understanding Chapter 5 - Futures (hybridized with some Chapter 2 - Up and Running stuff) and came up with something that I like in a portfolio project I'm working on. You can check out my actor that works with Futures here.
Future[Either[SomeResponse]]
. The Left
has an error that captures what might have gone wrong when the HttpClient hit the microserviceBoxOfficeApi
from Chapter 2 - Up and Running to abstract away the ask-y future-y stuff, and mixed that into the orchestrator actorFuture[Either[SomeResponse]]
is a hassle, so I used the EitherT
monad transformer from cats to make nice flatMapF
calls and for
comprehensions.Also, if there's a way I can simplify it down and adapt it to your TicketInfo example, I'd be happy to do a PR on this repo that builds a TicketInfo with calls to client actors that hit the webservices you refer to.
Hi, Raymond. I'm learning chapter 6 about akka remoting. When i used httpie to test the GoTick app
http put localhost:5000/events event=RHCP nrOfTickets:=10
HTTP/1.1 405 Method Not Allowed
Allow: GET
Content-Length: 47
Content-Type: text/plain; charset=UTF-8
Date: Wed, 19 Jul 2017 07:34:26 GMT
Server: GoTicks.com REST APIHTTP method not allowed, supported methods: GET
why is that ? I check the source code and didn't see PUT but POST. But it's still the problem
Hi,
I am having difficulty in understanding "The sender reference of an actor needs to be captured into a value before it can be safely used" at the summary of Chapter 5 Futures. Can you please explain more on "needs to be captured into a value"? Thanks.
What i currently understand is we can use
a. pipe(a future) to sender()
b. or methods from Future. for example, a future.onComplete(...) { sender() ! a successful value or a failure}
Thanks in advance,
Cheng
Hello, in the code examples (for example chapter 2), why is the code littered with comments such as:
<start id='"ch02_event_route'
Is there any reason for this? It is quite confusing when trying to understand the code, especially to a Scala beginner. Thanks.
It's hard for us to upgrade the version of Akka or some other third party library if we don't manage the dependencies from the ROOT/build.sbt.
My suggestion is we can put all the project settings into the ROOT/build.sbt to avoid change the version per project/build.sbt.
if(roles.contains("master")) {
Cluster(system).registerOnMemberUp {
val receptionist = system.actorOf(Props[JobReceptionist],
"receptionist")
println("Master node is ready.")
Great book Ray et al, best scala book so far. Using the
Could not get this command to work on windows 10 (I'm running the FrontendMain on one console, the BackendMain in another console via sbt). I have another terminal to send httpie commands.
C:\Users\andy>http PUT localhost:5000/events event=RHCP nrOfTickets:=10
HTTP/1.1 405 Method Not Allowed
Allow: GET
Content-Length: 47
Content-Type: text/plain; charset=UTF-8
Date: Thu, 18 May 2017 11:03:34 GMT
Server: GoTicks.com REST API
HTTP method not allowed, supported methods: GET
this works though
C:\Users\andy>http POST localhost:5000/events/CARS tickets:=100
HTTP/1.1 201 Created
Content-Length: 29
Content-Type: application/json
Date: Thu, 18 May 2017 10:58:43 GMT
Server: GoTicks.com REST API
{
"name": "CARS",
"tickets": 100
}
C:\Users\andy>http GET localhost:5000/events
HTTP/1.1 200 OK
Content-Length: 71
Content-Type: application/json
Date: Thu, 18 May 2017 11:25:20 GMT
Server: GoTicks.com REST API
{
"events": [
{
"name": "CARS",
"tickets": 100
},
{
"name": "RHCP",
"tickets": 10
}
]
}
In the first chapter up and running i am trying to understand how the fold works but can't figure out:
context.child(name).fold(create())(_ => sender() ! EventExists)
What happen if the child exist, are you still creating a new actor? is the neutral argument lazily evaluated ? why the create is not called in the case the list is not empty ?
Hi Ray,
You're probably working your way through updates since the chapter2
project has recent dependency versions, but I got to chapter6
today and it references old snapshots that didn't resolve for me and the build fails:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: io.spray#spray-can;1.2-M8-SNAPSHOT: not found
[warn] :: io.spray#spray-routing;1.2-M8-SNAPSHOT: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
Enjoying the book so far, thanks!
Hi,
I got these errors when use sbt assembly.
I used scalaVersion=2.12 & sbtVersion=1.0
[error] unresolved dependency: com.typesafe.sbt#sbt-native-packager;1.2.0: not found
[error] unresolved dependency: com.typesafe.sbt#sbt-multi-jvm;0.3.11: not found
"Listing 2.2 Running the JAR" is not working because is using a non exist object as main class.
I am going to create a pull request with the fixed build.sbt
sbt.ResolveException: unresolved dependency: com.typesafe.akka#akka-sbt-plugin;2.0.1: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:217)
at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:126)
at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:125)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:115)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:115)
at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:103)
at sbt.IvySbt.sbt$IvySbt$$action$1(Ivy.scala:48)
at sbt.IvySbt$$anon$3.call(Ivy.scala:57)
at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:98)
at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:81)
at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:102)
at xsbt.boot.Using$.withResource(Using.scala:11)
at xsbt.boot.Using$.apply(Using.scala:10)
at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:62)
at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:52)
at xsbt.boot.Locks$.apply0(Locks.scala:31)
at xsbt.boot.Locks$.apply(Locks.scala:28)
at sbt.IvySbt.withDefaultLogger(Ivy.scala:57)
at sbt.IvySbt.withIvy(Ivy.scala:98)
at sbt.IvySbt.withIvy(Ivy.scala:94)
at sbt.IvySbt$Module.withModule(Ivy.scala:115)
at sbt.IvyActions$.update(IvyActions.scala:125)
at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1223)
at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1221)
at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$74.apply(Defaults.scala:1244)
at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$74.apply(Defaults.scala:1242)
at sbt.Tracked$$anonfun$lastOutput$1.apply(Tracked.scala:35)
at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1246)
at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1241)
at sbt.Tracked$$anonfun$inputChanged$1.apply(Tracked.scala:45)
at sbt.Classpaths$.cachedUpdate(Defaults.scala:1249)
at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1214)
at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1192)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
at sbt.std.Transform$$anon$4.work(System.scala:64)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
at sbt.Execute.work(Execute.scala:244)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Hi guys,
I am confused with the code in Fault Tolerance example, when it watches a fileWatcher actor(line 57 context.watch(fileWatcher)), but it does not unwatch it when one of them is terminated.
Do we usually unwatch an actor when it is terminated? does it have any consequence if we don't unwatch?
Thanks in advance,
Cheng
[error] not found: https://repo1.maven.org/maven2/com/typesafe/sbt/sbt-native-packager_2.12_1.0/1.0.0/sbt-native-packager-1.0.0.pom [error] not found: C:\Users\shicheng_work_pc\.ivy2\local\com.typesafe.sbt\sbt-native-packager\scala_2.12\sbt_1.0\1.0.0\ivys\ivy.xml [error] not found: https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.typesafe.sbt/sbt-native-packager/scala_2.12/sbt_1.0/1.0.0/ivys/ivy.xml [error] not found: https://repo.typesafe.com/typesafe/ivy-releases/com.typesafe.sbt/sbt-native-packager/scala_2.12/sbt_1.0/1.0.0/ivys/ivy.xml [error] not found: http://repo.typesafe.com/typesafe/releases/com/typesafe/sbt/sbt-native-packager_2.12_1.0/1.0.0/sbt-native-packager-1.0.0.pom [error] not found: http://repo.typesafe.com/typesafe/snapshots/com/typesafe/sbt/sbt-native-packager_2.12_1.0/1.0.0/sbt-native-packager-1.0.0.pom [error] at lmcoursier.CoursierDependencyResolution.unresolvedWarningOrThrow(CoursierDependencyResolution.scala:245)
Has anyone encountered the same problem?
when there is only frontend up, why it keep sending Identify(path) or receiving ActorIdentity(path
, None)?
[ERROR] [12/29/2015 17:08:16.054] [frontend-akka.actor.default-dispatcher-4] [akka.tcp://[email protected]:2552/user/restInterface/lookupBoxOffice] Remote actor with path akka.tcp://[email protected]:2551/user/boxOffice is not available.
[WARN] [12/29/2015 17:08:19.067] [frontend-akka.actor.default-dispatcher-2] [akka.tcp://[email protected]:2552/user/restInterface/lookupBoxOffice] ???context.actorSelection(path)=ActorSelection[Anchor(akka.tcp://[email protected]:2551/), Path(/user/boxOffice)]
[ERROR] [12/29/2015 17:08:19.068] [frontend-akka.actor.default-dispatcher-2] [akka.tcp://[email protected]:2552/user/restInterface/lookupBoxOffice] Remote actor with path akka.tcp://[email protected]:2551/user/boxOffice is not available.
Fix issues like:
HelloWorld
[info] - must must reply when sending a string
marksu@~/work/githubScala/akka-in-action/chapter-up-and-running$ sbt run
...
marksu@~/work/githubScala/akka-in-action/chapter-up-and-running$ http PUT localhost:5000/events event=RHCP nrOfTickets:=10
HTTP/1.1 405 Method Not Allowed
Allow: GET
Content-Length: 47
Content-Type: text/plain; charset=UTF-8
Date: Mon, 21 Dec 2015 15:49:45 GMT
Server: GoTicks.com REST API
HTTP method not allowed, supported methods: GET
[info] SilentActor01Test:
[info] A Silent Actor
[info] - must change state when it receives a message, single threaded
[info] - must change state when it receives a message, multi-threaded *** FAILED ***
[info] java.lang.AssertionError: assertion failed: expected Vector(whisper1, whisper2), found Vector()
[info] at scala.Predef$.assert(Predef.scala:170)
[info] at akka.testkit.TestKitBase$class.expectMsg_internal(TestKit.scala:388)
[info] at akka.testkit.TestKitBase$class.expectMsg(TestKit.scala:364)
[info] at akka.testkit.TestKit.expectMsg(TestKit.scala:814)
[info] at aia.testdriven.SilentActor01Test$$anonfun$1$$anonfun$apply$mcV$sp$2.apply(SilentActor01Test.scala:40)
[info] at aia.testdriven.SilentActor01Test$$anonfun$1$$anonfun$apply$mcV$sp$2.apply(SilentActor01Test.scala:33)
[info] at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
[info] at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
[info] at org.scalatest.Transformer.apply(Transformer.scala:22)
[info] at org.scalatest.Transformer.apply(Transformer.scala:20)
[info] ...
[info] Run completed in 384 milliseconds.
[info] Total number of tests run: 2
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 1, failed 1, canceled 0, ignored 0, pending 0
[info] *** 1 TEST FAILED ***
[error] Failed tests:
[error] aia.testdriven.SilentActor01Test
[error] (test:testOnly) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 1 s, completed 9-Jun-2017 3:38:44 PM
Looks like:
silentActor ! SilentMessage("whisper1")
silentActor ! SilentMessage("whisper2")
never get executed before GetState
Any readme file for these programs ? This is what i get from running the first program
[info] Running aia.faulttolerance.dbstrategy1.LogProcessingApp
[ERROR] [08/12/2017 16:36:29.692] [logprocessing-akka.actor.default-dispatcher-4] [akka://logprocessing/user/file-watcher-supervisor] actor name [db-writer-mydatabase1] is not unique!
akka.actor.ActorInitializationException: akka://logprocessing/user/file-watcher-supervisor: exception during creation
In the second chapter / Listing 2.2 Running the JAR : When I execute the command : java -jar target/scala-2.11/goticks-assembly-1.0.jar I got this exception : Error: Could not find or load main class com.goticks.SingleNodeMain
When I run opt/workspace/IdeaProjects/akka-in-action$ sbt run
or opt/workspace/IdeaProjects/akka-in-action$ java -jar target/scala-2.10/all-assembly-1.0.jar
I get No main class detected.
I am running it from root directory.
sbt 1.0.0 alrealdy release 1.0.0
In chapter 3 on page 57 we implement SendingActor
and test it. The test uses expectMsgPF
because, as the book explains it:
"Since the SortEvents message contains a random vector of events, we canβt use an expectMsg(msg); we canβt formulate an exact match for it. In this case we use expectMsgPF , which takes a partial function just like the receive of the actor."
I replaced
expectMsgPF() {
case SortedEvents(events) =>
events.size must be(size)
unsorted.sortBy(_.id) must be(events)
}
with
expectMsg(SortedEvents(unsorted.sortBy(_.id)))
and it seems to work properly. Why is it not the optimal solution?
In chapter-stream graph.run() need implicit Materializer, but ActorMaterializer is not a akka.stream.Materializer in akka2.4.9γ
Error:(39, 20) could not find implicit value for parameter materializer: akka.stream.Materializer
runnableGraph.run().foreach{ result =>
But your
Source like these:
aia.stream.GenerateLogFile.scala
implicit val materializer = ActorMaterializer() //ActorMaterializer is not a akka.stream.Materializer
graph.run().foreach { result =>
akka.stream.scaladsl.Flow
//graph.run()(implicit materializer: Materializer) ...
def run()(implicit materializer: Materializer): Mat = materializer.materialize(this)
akka.stream.ActorMaterializer
object ActorMaterializer {
In CalculatorHistory you are using PersistentView to track message stream. In Akka 2.4 recommended way is to use Persistence Query.
For chapter-remoting project:
In file RestApi.scala
def eventsRoute =
pathPrefix("events") {
pathEndOrSingleSlash {
get {
// GET /events
onSuccess(getEvents()) { events =>
complete(OK, events)
}
}
}
}
The Intelj IDEA shows the error "too many argument" of function complete(OK, events)
Then I link to the source code of complete
, which owns the following signature:
def complete(m: β ToResponseMarshallable): StandardRoute =
StandardRoute(_.complete(m))
So I would like to know how to fix it? Thanks a bunch.
sbt update failed for this plugin
Hi and thanks a lot for your book!
When I sbt run com.goticks.FrontendRemoteDeployWatchMain
(without starting the backend node first) and send an HTTP request to the app (e.g., curl -s http://localhost:5000/events
), I get this:
[info] Running com.goticks.FrontendRemoteDeployWatchMain
[DEBUG] [04/22/2017 15:06:13.201] [run-main-0] [EventStream] StandardOutLogger started
INFO [Slf4jLogger]: Slf4jLogger started
[DEBUG] [04/22/2017 15:06:13.704] [run-main-0] [EventStream(akka://frontend)] logger log1-Slf4jLogger started
[DEBUG] [04/22/2017 15:06:13.705] [run-main-0] [EventStream(akka://frontend)] Default Loggers started
INFO [Remoting]: Starting remoting
INFO [Remoting]: Remoting started; listening on addresses :[akka.tcp://[email protected]:2552]
INFO [Remoting]: Remoting now listens on addresses: [akka.tcp://[email protected]:2552]
INFO [go-ticks]: RestApi bound to /0:0:0:0:0:0:0:0:5000
INFO [RemoteBoxOfficeForwarder]: switching to maybe active state
WARN [ReliableDeliverySupervisor]: Association with remote system [akka.tcp://[email protected]:2551] has failed, address is now gated for [5000] ms. Reason: [Association failed with [akka.tcp://[email protected]:2551]] Caused by: [Connection refused: no further information: /0.0.0.0:2551]
INFO [RemoteActorRefProvider$RemoteDeadLetterActorRef]: Message [akka.remote.RemoteWatcher$Heartbeat$] from Actor[akka://frontend/system/remote-watcher#801800298] to Actor[akka://frontend/deadLetters] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
INFO [RemoteActorRef]: Message [akka.remote.DaemonMsgCreate] from Actor[akka://frontend/deadLetters] to Actor[akka.tcp://[email protected]:2551/remote] was not delivered. [2] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
INFO [RemoteActorRef]: Message [com.goticks.BoxOffice$GetEvents$] from Actor[akka://frontend/temp/$a] to Actor[akka.tcp://[email protected]:2551/remote/akka.tcp/[email protected]:2552/user/forwarder/boxOffice#-900370488] was not delivered. [3] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
INFO [RemoteActorRefProvider$RemoteDeadLetterActorRef]: Message [akka.remote.RemoteWatcher$Heartbeat$] from Actor[akka://frontend/system/remote-watcher#801800298] to Actor[akka://frontend/deadLetters] was not delivered. [4] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
INFO [RemoteActorRefProvider$RemoteDeadLetterActorRef]: Message [akka.remote.RemoteWatcher$Heartbeat$] from Actor[akka://frontend/system/remote-watcher#801800298] to Actor[akka://frontend/deadLetters] was not delivered. [5] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
INFO [RemoteActorRefProvider$RemoteDeadLetterActorRef]: Message [akka.remote.RemoteWatcher$Heartbeat$] from Actor[akka://frontend/system/remote-watcher#801800298] to Actor[akka://frontend/deadLetters] was not delivered. [6] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
INFO [RemoteActorRefProvider$RemoteDeadLetterActorRef]: Message [akka.remote.RemoteWatcher$Heartbeat$] from Actor[akka://frontend/system/remote-watcher#801800298] to Actor[akka://frontend/deadLetters] was not delivered. [7] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
INFO [RemoteActorRefProvider$RemoteDeadLetterActorRef]: Message [akka.remote.RemoteWatcher$Heartbeat$] from Actor[akka://frontend/system/remote-watcher#801800298] to Actor[akka://frontend/deadLetters] was not delivered. [8] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
WARN [ReliableDeliverySupervisor]: Association with remote system [akka.tcp://[email protected]:2551] has failed, address is now gated for [5000] ms. Reason: [Association failed with [akka.tcp://[email protected]:2551]] Caused by: [Connection refused: no further information: /0.0.0.0:2551]
INFO [RemoteActorRefProvider$RemoteDeadLetterActorRef]: Message [akka.remote.RemoteWatcher$Heartbeat$] from Actor[akka://frontend/system/remote-watcher#801800298] to Actor[akka://frontend/deadLetters] was not delivered. [9] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
INFO [RemoteActorRefProvider$RemoteDeadLetterActorRef]: Message [akka.remote.RemoteWatcher$Heartbeat$] from Actor[akka://frontend/system/remote-watcher#801800298] to Actor[akka://frontend/deadLetters] was not delivered. [10] dead letters encountered, no more dead letters will be logged. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
INFO [RemoteBoxOfficeForwarder]: switching to maybe active state
INFO [RemoteBoxOfficeForwarder]: Actor $actorRef terminated.
INFO [RemoteBoxOfficeForwarder]: switching to deploying state
INFO [RemoteBoxOfficeForwarder]: switching to maybe active state
INFO [RemoteBoxOfficeForwarder]: Actor $actorRef terminated.
INFO [RemoteBoxOfficeForwarder]: switching to deploying state
INFO [RemoteBoxOfficeForwarder]: switching to maybe active state
INFO [RemoteBoxOfficeForwarder]: Actor $actorRef terminated.
INFO [RemoteBoxOfficeForwarder]: switching to deploying state
INFO [RemoteBoxOfficeForwarder]: switching to maybe active state
INFO [RemoteBoxOfficeForwarder]: Actor $actorRef terminated.
INFO [RemoteBoxOfficeForwarder]: switching to deploying state
INFO [RemoteBoxOfficeForwarder]: switching to maybe active state
INFO [RemoteBoxOfficeForwarder]: Actor $actorRef terminated.
INFO [RemoteBoxOfficeForwarder]: switching to deploying state
INFO [RemoteBoxOfficeForwarder]: switching to maybe active state
// A lot of the above...
ERROR [ActorSystemImpl]: Error during processing of request: 'Ask timed out on [Actor[akka://frontend/user/forwarder#204738603]] after [20000 ms]. Sender[null] sent message of type "com.goticks.BoxOffice$GetEvents$".'. Completing with 500 Internal Server Error response.
WARN [ReliableDeliverySupervisor]: Association with remote system [akka.tcp://[email protected]:2551] has failed, address is now gated for [5000] ms. Reason: [Association failed with [akka.tcp://[email protected]:2551]] Caused by: [Connection refused: no further information: /0.0.0.0:2551]
I was under the impression that the frontend could create the backend on demand.
Thanks for your help!
Hi, in this chapter, in "JobMaster.scala", the merge function can be simple because we can use reduceLeft instead of foldLeft.
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: commons-io#commons-io;2.4: configuration not found in commons-io#commons-io;2.4: 'master(compile)'. Missing configuration: 'compile'. It was required from org.vafer#jdeb;1.3 compile
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] commons-io:commons-io:2.4
[warn] +- org.vafer:jdeb:1.3
[warn] +- com.typesafe.sbt:sbt-native-packager:1.0.0 (scalaVersion=2.10, sbtVersion=0.13) (/Users/hary/workspace/scala/akka-in-action/chapter-conf-deploy/project/plugins.sbt#L1-2)
[warn] +- default:chapter-conf-deploy-build:0.1-SNAPSHOT (scalaVersion=2.10, sbtVersion=0.13)
sbt.ResolveException: unresolved dependency: commons-io#commons-io;2.4: configuration not found in commons-io#commons-io;2.4: 'master(compile)'. Missing configuration: 'compile'. It was required from org.vafer#jdeb;1.3 compile
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:313)
at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:191)
at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:168)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:156)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:156)
at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:133)
at sbt.IvySbt.sbt$IvySbt$$action$1(Ivy.scala:57)
at sbt.IvySbt$$anon$4.call(Ivy.scala:65)
at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:93)
at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:78)
at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:97)
at xsbt.boot.Using$.withResource(Using.scala:10)
at xsbt.boot.Using$.apply(Using.scala:9)
at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:58)
at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:48)
at xsbt.boot.Locks$.apply0(Locks.scala:31)
at xsbt.boot.Locks$.apply(Locks.scala:28)
at sbt.IvySbt.withDefaultLogger(Ivy.scala:65)
at sbt.IvySbt.withIvy(Ivy.scala:128)
at sbt.IvySbt.withIvy(Ivy.scala:125)
at sbt.IvySbt$Module.withModule(Ivy.scala:156)
at sbt.IvyActions$.updateEither(IvyActions.scala:168)
at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1481)
at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1477)
at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$121.apply(Defaults.scala:1512)
at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$121.apply(Defaults.scala:1510)
at sbt.Tracked$$anonfun$lastOutput$1.apply(Tracked.scala:37)
at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1515)
at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1509)
at sbt.Tracked$$anonfun$inputChanged$1.apply(Tracked.scala:60)
at sbt.Classpaths$.cachedUpdate(Defaults.scala:1532)
at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1459)
at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1411)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[error] (*:update) sbt.ResolveException: unresolved dependency: commons-io#commons-io;2.4: configuration not found in commons-io#commons-io;2.4: 'master(compile)'. Missing configuration: 'compile'. It was required from org.vafer#jdeb;1.3 compile
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.