zoukankan      html  css  js  c++  java
  • learning scala akka tell pattern(二)

    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], name = "DonutInfoActor")
    
        import  DonutStoreProtocal._
        donutInActor ! Info("panzidong running!")
    
        val isTerminated = system.terminate()
    
        object DonutStoreProtocal {
          case class Info(name: String)
        }
    
        class DonutInActor extends Actor with ActorLogging{
          import  Tutorial_02_Tell_Pattern.DonutStoreProtocal._
    
          override def receive: Receive = {
            case Info(name) =>{
              log.info(s"Found $name dount")
            }
          }
        }
    
    }

    result:

    Step 1: Create an actory system
    [INFO] [08/23/2019 16:14:12.079] [DonutStoreActorSystem-akka.actor.default-dispatcher-3] [akka://DonutStoreActorSystem/user/DonutInfoActor] Found panzidong running! dount
  • 相关阅读:
    显而易见的python
    GitHub 使用教程图文详解
    linux下搭建hexo环境
    linux 删除软链接
    Django2.1入门教程
    windows下安装PyQt4
    python3 Flask安装
    学习之源
    白话C++系列教程
    面试笔试试题精选
  • 原文地址:https://www.cnblogs.com/lianghong881018/p/11400746.html
Copyright © 2011-2022 走看看