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/
- 浏览: 2551832 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
发表评论
-
Update Site will come soon
2021-06-02 04:10 1678I am still keep notes my tech n ... -
NodeJS12 and Zlib
2020-04-01 07:44 476NodeJS12 and Zlib It works as ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 337Traefik 2020(1)Introduction and ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 436Private Registry 2020(1)No auth ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 385Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 478NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 423Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 337Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 247GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 451GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 328GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 314Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 318Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 294Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 312Serverless with NodeJS and Tenc ... -
NodeJS MySQL Library and npmjs
2020-02-07 06:21 288NodeJS MySQL Library and npmjs ... -
Python Library 2019(1)requests and aiohttp
2019-12-18 01:12 261Python Library 2019(1)requests ... -
Hadoop Docker 2019 Version 3.2.1
2019-12-10 07:39 294Hadoop Docker 2019 Version 3.2. ... -
Nginx and Proxy 2019(1)Nginx Enable Lua and Parse JSON
2019-12-03 04:17 448Nginx and Proxy 2019(1)Nginx En ... -
Data Solution 2019(13)Docker Zeppelin Notebook and Memory Configuration
2019-11-09 07:15 294Data Solution 2019(13)Docker Ze ...
相关推荐
在使用`akka-actor-1.0-RC2.jar`时,可能还需要其他的依赖包,如Scala库(如果使用Scala编写Actor),或者其他Akka模块如`akka-cluster`(用于构建分布式系统)和`akka-logback`(日志集成)。确保正确配置这些依赖...
在Java和Scala的世界里,Akka是一个强大的工具库,它提供了构建高度可扩展、反应式应用程序的框架。Akka Typed Actor是Akka框架中的一个重要组件,它是对传统Actor模型的升级,引入了类型安全的接口,为开发者带来了...
标题中的“用Scala写的akka actor简单demo”指的是一个使用Scala编程语言编写的Akka Actor系统的基本示例。Akka是轻量级、基于actor模型的框架,它用于构建高度并发、分布式和容错的应用程序。Scala是多范式编程语言...
这是一个Java Archive(JAR)文件,包含了Akka Actor模块的类库,供Java或Scala项目引用。在Java项目中,可以通过在类路径中包含这个JAR文件,导入必要的依赖,以便使用Akka Actor的功能。对于Maven或Gradle用户,...
akka-actor_2.11 jar包
Scala 中的简单 Akka Remote 示例 这个存储库包含一个简单的 akka 远程示例。 它展示了如何在同一个项目中创建远程和本地 actor。它还展示了如何读取和解释不同的配置。
Akka是JAVA虚拟机JVM平台上构建高并发、分布式和容错应用的工具包和...Akka用Scala语言写成,同时提供了Scala和JAVA的开发接口。 Akka处理并发的方法基于Actor模型。在Akka里,Actor之间通信的唯一机制就是消息传递。
`akka-play-scala-demo` 是一个基于 Akka、Play 和 Scala 的示例项目,它展示了如何在这些技术栈中构建高效、可扩展的Web应用程序。Akka 是一个用于构建高度并发、分布式和反应式应用的框架,而 Play 是一个用于构建...
akka-actor_2.12 jar包
- **Actor系统(Actor System)**:Actor系统的概念类似于进程或线程的概念,但它是Akka中的核心组件,用于管理Actor的生命周期。 - **Actor References, Paths and Addresses**:Actor之间的通信是通过发送消息完成...
6. **Finite State Machine (FSM)**:Akka支持将Actor设计为有限状态机,允许Actor根据接收到的消息改变其状态,简化了复杂逻辑的管理。 7. ** Persistence**:Akka的持久化特性使得Actor能够保存和恢复状态,即使...
每个用户、每张报表均作为独立的actor, 通过akka Persistence持久化各个节点的状态,并额外获得一个可自动更新的分布式缓存。对长时间未使用的节点 可以自动下线,以释放系统资源。高可用,可横向扩展至多节点。完全...
Akka是JAVA虚拟机JVM平台上构建高并发、分布式和容错应用的工具包和...Akka用Scala语言写成,同时提供了Scala和JAVA的开发接口。 Akka处理并发的方法基于Actor模型。在Akka里,Actor之间通信的唯一机制就是消息传递。
消息模式的Actor实现是响应式架构中的一个重要组件,而Akka框架则是Scala语言中实现这一模式的首选工具。 Akka是由Lightbend公司开发的一个开源框架,专门用于构建高度并发、分布式和容错的系统。它基于Actor模型,...
标签“Akka scala 并发 actor”则进一步具体化了文档内容,即深入探讨了Akka中的actor并发模型。 文档内容涉及到以下几个核心知识点: 1. 概述和入门: - Akka是什么?它是一个开源的工具集,用来简化在Java...
"scala-intellij-bin-2021.3.6.zip"是一个压缩包,包含了用于在IntelliJ IDEA中支持Scala开发的特定版本插件。 这个版本的Scala插件(2021.3.6)是为IntelliJ IDEA 2021.3系列构建的,它提供了丰富的功能,以帮助...
Akka HTTP,作为Scala和Java平台上的一个高性能、低级别的HTTP服务器和客户端库,是Akka框架的一个重要组成部分。它允许开发者构建可扩展、反应式、容错的应用程序。在描述中的"akka-http-1.0-RC2.jar.zip"文件,...
5. **Actor模型**:Scala集成了Akka框架,其中的Actor模型为并发和分布式计算提供了基础。Actors是轻量级的并发实体,通过消息传递进行通信,避免了共享状态的问题。 6. **模式匹配**:Scala的模式匹配允许开发者在...
5. ** Actors模型**:Scala内置了Akka库,提供了Actor模型,用于构建并发和分布式系统。Actors是轻量级的并发实体,它们通过消息传递进行通信,避免了共享状态的复杂性。 6. **集合库**:Scala的集合库是其强大功能...
它源于Actor模型,并与Scala和Java生态系统深度整合。Kafka则是一个分布式流处理平台,常用于实时数据管道和消息系统。将Akka Streams与Kafka结合,可以构建高效、可扩展的数据处理流水线。 在"akka-streams-kafka-...