`
sillycat
  • 浏览: 2551548 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Akka(6)Remote Actor - akka-sample-remote-scala

 
阅读更多

Akka(6)Remote Actor - akka-sample-remote-scala

1. Installation of Akka
Download the akka_2.10-2.3.4.zip, put it in the working place.

Deploy my jar to the deploy directory.
>cp target/scala-2.10/sillycat-akka_2.10-1.0.jar /opt/akka/deploy/

The configuration file is in /opt/akka/config/application.conf

2. Find the Example
http://www.typesafe.com/platform/getstarted

After run activator I can create a sample project of remote akka with the search name of akka-sample-remote-scala
activator is really a good tool. I will try to use that later.

After that I have this project on my local akka-sample-remote-scala
And here are a lot of other examples https://github.com/akka/akka/tree/master/akka-samples

3. Implementation
Reading code from akka-sample-remote-scala

4. Deployment
Error Message
bin/akka com.sillycat.akka.server.EventServiceRemoteApp Exception in thread "main" java.lang.NoClassDefFoundError: scala/Function1 at akka.kernel.Main.main(Main.scala) Caused by: java.lang.ClassNotFoundException: scala.Function1 at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

Solution:
[ -n "$AKKA_CLASSPATH" ] || AKKA_CLASSPATH="$AKKA_HOME/lib/scala-library-2.10.4.jar:$AKKA_HOME/config:$AKKA_HOME/lib/akka/*"

Finally I found that because we did not find the scala-library because of the version name. so I change it to scala-library-2.10.4.jar.

Then it runs, but it complains about some ClassNotFound Exception. So I deploy the assembly jar there.
>bin/akka com.sillycat.akka.server.EventServiceRemoteApp

It runs and the codes are in sample project sillycat-akka.

Warning Message
Successfully started Akka SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Solution:
Go the lib/akka directory
>wget http://central.maven.org/maven2/org/slf4j/slf4j-log4j12/1.7.7/slf4j-log4j12-1.7.7.jar
>rm -fr slf4j-api-1.7.5.jar
>wget http://central.maven.org/maven2/org/slf4j/slf4j-log4j12/1.7.7/slf4j-log4j12-1.7.7.jar
>mkdir install
>cd install/
>wget http://apache.mirrors.lucidnetworks.net/logging/log4j/1.2.17/log4j-1.2.17.tar.gz
>tar zxvf log4j-1.2.17.tar.gz 
>cp apache-log4j-1.2.17/log4j-1.2.17.jar ../

Make sure these jars are there under lib/akka/
log4j-1.2.17.jar
slf4j-api-1.7.7.jar
slf4j-log4j12-1.7.7.jar


About the Logging Message
Running sbt in debug Level
>sbt test --debug

Actually my logging information is not showing because I am using slf4j-simple
My dependencies are as follow:
    "com.typesafe"              %% "scalalogging-slf4j"                % "1.0.1",
    "org.slf4j"           %  "slf4j-simple"                  % "1.7.7",
    //"org.slf4j"           %  "slf4j-log4j12"                 % "1.7.7",
    "org.slf4j"           %  "slf4j-api"                     % "1.7.7",

The configuration file should be as follow, and the file name should be simple logger.properties:

# SLF4J's SimpleLogger configuration file
# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err.

# Default logging detail level for all instances of SimpleLogger.
# Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, defaults to "info".
org.slf4j.simpleLogger.defaultLogLevel=debug

# Logging detail level for a SimpleLogger instance named "xxxxx".
# Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, the default logging detail level is used.
#org.slf4j.simpleLogger.log.xxxxx=

# Set to true if you want the current date and time to be included in output messages.
# Default is false, and will output the number of milliseconds elapsed since startup.
#org.slf4j.simpleLogger.showDateTime=false

# The date and time format to be used in the output messages.
# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat.
# If the format is not specified or is invalid, the default format is used.
# The default format is yyyy-MM-dd HH:mm:ss:SSS Z.
#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z

# Set to true if you want to output the current thread name.
# Defaults to true.
#org.slf4j.simpleLogger.showThreadName=true

# Set to true if you want the Logger instance name to be included in output messages.
# Defaults to true.
#org.slf4j.simpleLogger.showLogName=true

# Set to true if you want the last component of the name to be included in output messages.
# Defaults to false.
#org.slf4j.simpleLogger.showShortLogName=false

If I want the log4j working, I need to change the dependencies as follow:
    "com.typesafe"              %% "scalalogging-slf4j"                % "1.0.1",
    "org.slf4j"           %  "slf4j-simple"                  % "1.7.7",
    //"org.slf4j"           %  "slf4j-log4j12"                 % "1.7.7",
    "org.slf4j"           %  "slf4j-api"                     % "1.7.7", 

Error Message:
[INFO] [08/11/2014 14:40:35.887] [EventServiceLocalSystem-akka.actor.default-dispatcher-2] [akka://EventServiceLocalSystem/deadLetters] Message [com.sillycat.akka.model.EventMessage] from Actor[akka://EventServiceLocalSystem/temp/$a] to Actor[akka://EventServiceLocalSystem/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'.

Error Message:
Can't serialize a non-protobuf message using protobuf

Solution:
"com.typesafe.akka"   %% "akka-remote"                   % "2.3.4"

It is not working if I deploy to akka and run with bin/akka. 

5. Another Example
Search for akka-sample-cluster-scala



References:
http://agiledon.github.io/blog/2014/02/18/remote-actor-in-akka/
http://java.dzone.com/articles/how-configure-slf4j-different
http://sillycat.iteye.com/blog/2100232

http://doc.akka.io/docs/akka/snapshot/scala/remoting.html#remote-configuration-scala
http://doc.akka.io/docs/akka/snapshot/scala/remoting.html

Serialization
http://doc.akka.io/docs/akka/snapshot/scala/serialization.html#serialization-scala

http://www.typesafe.com/activator/template/akka-sample-remote-scala?_ga=1.191183337.2134491737.1406929595
http://alvinalexander.com/scala/simple-akka-actors-remote-example
http://alvinalexander.com/scala/akka-remote-sending-objects-messages
https://github.com/alvinj/AkkaRemoteActorsHelloWorld.git

https://typesafe.com/activator/template/akka-sample-cluster-scala

http://doc.akka.io/docs/akka/2.1.2/cluster/cluster-usage-scala.html

http://tersesystems.com/2014/06/25/akka-clustering/

分享到:
评论

相关推荐

    akka-actor-1.0-RC2.jar.zip

    在使用`akka-actor-1.0-RC2.jar`时,可能还需要其他的依赖包,如Scala库(如果使用Scala编写Actor),或者其他Akka模块如`akka-cluster`(用于构建分布式系统)和`akka-logback`(日志集成)。确保正确配置这些依赖...

    akka-typed-actor-1.0-RC2.jar.zip

    在Java和Scala的世界里,Akka是一个强大的工具库,它提供了构建高度可扩展、反应式应用程序的框架。Akka Typed Actor是Akka框架中的一个重要组件,它是对传统Actor模型的升级,引入了类型安全的接口,为开发者带来了...

    用Scala写的akka actor简单demo

    标题中的“用Scala写的akka actor简单demo”指的是一个使用Scala编程语言编写的Akka Actor系统的基本示例。Akka是轻量级、基于actor模型的框架,它用于构建高度并发、分布式和容错的应用程序。Scala是多范式编程语言...

    akka-actor-1.1.2.jar.zip

    这是一个Java Archive(JAR)文件,包含了Akka Actor模块的类库,供Java或Scala项目引用。在Java项目中,可以通过在类路径中包含这个JAR文件,导入必要的依赖,以便使用Akka Actor的功能。对于Maven或Gradle用户,...

    akka-actor_2.11 jar包

    akka-actor_2.11 jar包

    akka-remote-simple-scala:Scala 中一个简单的 akka 远程示例

    Scala 中的简单 Akka Remote 示例 这个存储库包含一个简单的 akka 远程示例。 它展示了如何在同一个项目中创建远程和本地 actor。它还展示了如何读取和解释不同的配置。

    akka-actor_2.13-2.6.1.jar

    Akka是JAVA虚拟机JVM平台上构建高并发、分布式和容错应用的工具包和...Akka用Scala语言写成,同时提供了Scala和JAVA的开发接口。 Akka处理并发的方法基于Actor模型。在Akka里,Actor之间通信的唯一机制就是消息传递。

    akka-play-scala-demo:akka-播放-scala-demo

    `akka-play-scala-demo` 是一个基于 Akka、Play 和 Scala 的示例项目,它展示了如何在这些技术栈中构建高效、可扩展的Web应用程序。Akka 是一个用于构建高度并发、分布式和反应式应用的框架,而 Play 是一个用于构建...

    akka-actor_2.12 jar包

    akka-actor_2.12 jar包

    scala akka

    - **Actor系统(Actor System)**:Actor系统的概念类似于进程或线程的概念,但它是Akka中的核心组件,用于管理Actor的生命周期。 - **Actor References, Paths and Addresses**:Actor之间的通信是通过发送消息完成...

    Scala Akka项目源码

    6. **Finite State Machine (FSM)**:Akka支持将Actor设计为有限状态机,允许Actor根据接收到的消息改变其状态,简化了复杂逻辑的管理。 7. ** Persistence**:Akka的持久化特性使得Actor能够保存和恢复状态,即使...

    基于akka-http、akka-cluster、akka-stream 构建的报表工具

    每个用户、每张报表均作为独立的actor, 通过akka Persistence持久化各个节点的状态,并额外获得一个可自动更新的分布式缓存。对长时间未使用的节点 可以自动下线,以释放系统资源。高可用,可横向扩展至多节点。完全...

    akka-actor_2.13-2.6.5.jar

    Akka是JAVA虚拟机JVM平台上构建高并发、分布式和容错应用的工具包和...Akka用Scala语言写成,同时提供了Scala和JAVA的开发接口。 Akka处理并发的方法基于Actor模型。在Akka里,Actor之间通信的唯一机制就是消息传递。

    响应式架构 消息模式Actor实现与Scala.Akka应用集成

    消息模式的Actor实现是响应式架构中的一个重要组件,而Akka框架则是Scala语言中实现这一模式的首选工具。 Akka是由Lightbend公司开发的一个开源框架,专门用于构建高度并发、分布式和容错的系统。它基于Actor模型,...

    Akka Scala 学习高清原版pdf

    标签“Akka scala 并发 actor”则进一步具体化了文档内容,即深入探讨了Akka中的actor并发模型。 文档内容涉及到以下几个核心知识点: 1. 概述和入门: - Akka是什么?它是一个开源的工具集,用来简化在Java...

    scala-intellij-bin-2021.3.6.zip

    "scala-intellij-bin-2021.3.6.zip"是一个压缩包,包含了用于在IntelliJ IDEA中支持Scala开发的特定版本插件。 这个版本的Scala插件(2021.3.6)是为IntelliJ IDEA 2021.3系列构建的,它提供了丰富的功能,以帮助...

    akka-http-1.0-RC2.jar.zip

    Akka HTTP,作为Scala和Java平台上的一个高性能、低级别的HTTP服务器和客户端库,是Akka框架的一个重要组成部分。它允许开发者构建可扩展、反应式、容错的应用程序。在描述中的"akka-http-1.0-RC2.jar.zip"文件,...

    Scala-2.11.1.zip

    5. **Actor模型**:Scala集成了Akka框架,其中的Actor模型为并发和分布式计算提供了基础。Actors是轻量级的并发实体,通过消息传递进行通信,避免了共享状态的问题。 6. **模式匹配**:Scala的模式匹配允许开发者在...

    scala-2.12.11.zip

    5. ** Actors模型**:Scala内置了Akka库,提供了Actor模型,用于构建并发和分布式系统。Actors是轻量级的并发实体,它们通过消息传递进行通信,避免了共享状态的复杂性。 6. **集合库**:Scala的集合库是其强大功能...

    akka-streams-kafka-examples-源码.rar

    它源于Actor模型,并与Scala和Java生态系统深度整合。Kafka则是一个分布式流处理平台,常用于实时数据管道和消息系统。将Akka Streams与Kafka结合,可以构建高效、可扩展的数据处理流水线。 在"akka-streams-kafka-...

Global site tag (gtag.js) - Google Analytics