Making it green
This commit is contained in:
parent
e5b3fd00a2
commit
aa4ad6f3c3
20 changed files with 155 additions and 104 deletions
|
|
@ -363,7 +363,7 @@ class ActorDocSpec extends AkkaSpec(Map("akka.loglevel" -> "INFO")) {
|
|||
val actorA, actorB, actorC, actorD = system.actorOf(Props.empty)
|
||||
//#ask-pipeTo
|
||||
import akka.pattern.{ ask, pipe }
|
||||
|
||||
import system.dispatcher // The ExecutionContext that will be used
|
||||
case class Result(x: Int, s: String, d: Double)
|
||||
case object Request
|
||||
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ class Worker extends Actor with ActorLogging {
|
|||
counterService ! Increment(1)
|
||||
|
||||
// Send current progress to the initial sender
|
||||
import context.dispatcher // Use this Actors' Dispatcher as ExecutionContext
|
||||
counterService ? GetCurrentCount map {
|
||||
case CurrentCount(_, count) ⇒ Progress(100.0 * count / totalCount)
|
||||
} pipeTo progressListener.get
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
|
||||
*/
|
||||
|
||||
package docs.camel
|
||||
|
||||
import language.postfixOps
|
||||
|
||||
object Consumers {
|
||||
def foo = {
|
||||
//#Consumer1
|
||||
|
|
@ -53,7 +59,7 @@ object Consumers {
|
|||
{
|
||||
//#Consumer4
|
||||
import akka.camel.{ CamelMessage, Consumer }
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.util.duration._
|
||||
|
||||
class Consumer4 extends Consumer {
|
||||
def endpointUri = "jetty:http://localhost:8877/camel/default"
|
||||
|
|
|
|||
|
|
@ -1,8 +1,14 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
|
||||
*/
|
||||
|
||||
package docs.camel
|
||||
|
||||
import akka.camel.CamelMessage
|
||||
import akka.actor.Status.Failure
|
||||
|
||||
import language.existentials
|
||||
|
||||
object CustomRoute {
|
||||
{
|
||||
//#CustomRoute
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package docs.camel
|
|||
import akka.actor.{ Props, ActorSystem }
|
||||
import akka.camel.CamelExtension
|
||||
|
||||
import language.postfixOps
|
||||
|
||||
object Introduction {
|
||||
def foo = {
|
||||
//#Consumer-mina
|
||||
|
|
@ -75,7 +77,7 @@ object Introduction {
|
|||
{
|
||||
//#CamelActivation
|
||||
import akka.camel.{ CamelMessage, Consumer }
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.util.duration._
|
||||
|
||||
class MyEndpoint extends Consumer {
|
||||
def endpointUri = "mina:tcp://localhost:6200?textline=true"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package docs.camel
|
||||
|
||||
import akka.camel.CamelExtension
|
||||
import language.postfixOps
|
||||
|
||||
object Producers {
|
||||
{
|
||||
|
|
@ -16,7 +17,7 @@ object Producers {
|
|||
//#Producer1
|
||||
//#AskProducer
|
||||
import akka.pattern.ask
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.util.duration._
|
||||
implicit val timeout = Timeout(10 seconds)
|
||||
|
||||
val system = ActorSystem("some-system")
|
||||
|
|
|
|||
|
|
@ -1,34 +1,30 @@
|
|||
package docs.camel
|
||||
|
||||
object QuartzExample {
|
||||
//#Quartz
|
||||
import akka.actor.{ ActorSystem, Props }
|
||||
|
||||
{
|
||||
//#Quartz
|
||||
import akka.actor.{ ActorSystem, Props }
|
||||
import akka.camel.{ Consumer }
|
||||
|
||||
import akka.camel.{ Consumer }
|
||||
class MyQuartzActor extends Consumer {
|
||||
|
||||
class MyQuartzActor extends Consumer {
|
||||
def endpointUri = "quartz://example?cron=0/2+*+*+*+*+?"
|
||||
|
||||
def endpointUri = "quartz://example?cron=0/2+*+*+*+*+?"
|
||||
def receive = {
|
||||
|
||||
def receive = {
|
||||
case msg ⇒ println("==============> received %s " format msg)
|
||||
|
||||
case msg ⇒ println("==============> received %s " format msg)
|
||||
} // end receive
|
||||
|
||||
} // end receive
|
||||
} // end MyQuartzActor
|
||||
|
||||
} // end MyQuartzActor
|
||||
object MyQuartzActor {
|
||||
|
||||
object MyQuartzActor {
|
||||
|
||||
def main(str: Array[String]) {
|
||||
val system = ActorSystem("my-quartz-system")
|
||||
system.actorOf(Props[MyQuartzActor])
|
||||
} // end main
|
||||
|
||||
} // end MyQuartzActor
|
||||
//#Quartz
|
||||
}
|
||||
def main(str: Array[String]) {
|
||||
val system = ActorSystem("my-quartz-system")
|
||||
system.actorOf(Props[MyQuartzActor])
|
||||
} // end main
|
||||
|
||||
} // end MyQuartzActor
|
||||
//#Quartz
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ object FutureDocSpec {
|
|||
|
||||
class FutureDocSpec extends AkkaSpec {
|
||||
import FutureDocSpec._
|
||||
|
||||
import system.dispatcher
|
||||
"demonstrate usage custom ExecutionContext" in {
|
||||
val yourExecutorServiceGoesHere = java.util.concurrent.Executors.newSingleThreadExecutor()
|
||||
//#diy-execution-context
|
||||
|
|
@ -150,7 +150,7 @@ class FutureDocSpec extends AkkaSpec {
|
|||
result must be(4)
|
||||
|
||||
val failedFilter = future1.filter(_ % 2 == 1).recover {
|
||||
case m: MatchError ⇒ 0 //When filter fails, it will have a MatchError
|
||||
case m: NoSuchElementException ⇒ 0 //When filter fails, it will have a java.util.NoSuchElementException
|
||||
}
|
||||
val result2 = Await.result(failedFilter, 1 second)
|
||||
result2 must be(0) //Can only be 0 when there was a MatchError
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue