package com.example import akka.actor.ActorSystem import scala.util.{Failure, Success} import scala.concurrent.ExecutionContext.Implicits.global object Tutorial_01_ActorSystem_Introduction extends App { println("Step1 : Create an actor system")…
package com.example import akka.actor._ import akka.util.Timeout object Tutorial_03_Ask_Pattern extends App { val system = ActorSystem("DonutStoreActorySystem") val donutInfoActor = system.actorOf(Props[DonutInfoActor], name="DonutInfoActor…
package com.example import akka.actor._ object Tutorial_02_Tell_Pattern extends App { println("Step 1: Create an actory system") val system = ActorSystem("DonutStoreActorSystem") val donutInActor = system.actorOf(Props[DonutInActor], n…
Scala collection such as List or Sequence or even an Array to variable argument function using the syntax :_ *. code : def printReport(names: String*) { println(s"""Donut Report = ${names.mkString(" - ")}""") } prin…
println("Step 1: How to create a wrapper String class which will extend the String type") class DonutString(s: String) { def isFavoriteDonut: Boolean = s == "Glazed Donut" } println("\nStep 2: How to create an implicit function to…
import java.util.concurrent.{ExecutorService, Executors, TimeUnit} import akka.actor.{Actor, ActorSystem, Props} import akka.util.Timeout import scala.concurrent.{Await, ExecutionContext} import scala.concurrent.duration.Duration Runnable 无返回值 class…
对于 A => B => C 这种 future 之间的操作,akka 默认会自动的按照顺序执行,但对于数据库操作来说,我们希望几个操作顺序执行,就需要使用语法来声明 有两种声明 future 先后关系的方法,第一种是 flatMap,第二种是 for import scala.concurrent.Future import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.blocking…
this article show you how to create a SBT project with IDEA. prerequisite: 1.JDK8 2.Scala 2.11.8 3.Intellij IDEA 2016.3 1.create a new project from: File>New>Project…
Akka基础 Akka笔记之Actor简介  Akka中的Actor遵循Actor模型.你可以把Actor当作是人.这些人不会亲自去和别人交谈.他们只通过邮件来交流.  1. 消息传递 2. 并发 3. 异常处理 4. 多任务 5. 消息链 Akka笔记之消息传递 消息发送给actor代理: 消息是不可变对象(可带有属性的case class): 分发器dispatcher和邮箱: dispatcher从actorRef取出一条消息放在目标actor邮箱中,然后放mailbox放在一个Threa…
scala中特质定义:包括一些字段,行为(方法/函数/动作)和一些未实现的功能接口的集合,能够方便的实现扩展或混入到已有类或抽象类中. scala中特质(trait)是一个非常实用的特性,在程序设计中能够 更好的抽象现实.使程序更关注各自功能和更好的将程序拆分成多个特质模块,使程序具有更强的扩展性.熟悉java的同学.能够将特质理解为抽象类.可是scala中能够在一个类中同一时候混入多个特质(使用extends 或with).而java中一个类仅仅能继承一个抽象类,假设要实现多个抽象类就必需使用…