actor

How can I use Akka Actors in a Java application?

做~自己de王妃 提交于 2019-12-01 06:06:56
I would like to use Akka actors in Java. I downloaded the akka-1.0.zip and added akka-actor-1.0.jar to my "Build Path" in Eclipse. Then I wrote this Actor class: package com.example; import akka.actor.UntypedActor; public class MyActor extends UntypedActor { public void onReceive(Object message) throws IllegalArgumentException { if (message instanceof String) { System.out.println("Received: " + message); } else throw new IllegalArgumentException("Unknown message: " + message); } } But I get errors in Eclipse: The type scala.Option cannot be resolved. The type scala.Some cannot be resolved. The

性能优化之MySQL优化(慕课)

霸气de小男生 提交于 2019-12-01 05:08:19
MySQL数据库优化 1-1MySQL优化简介 数据库优化的目的 避免出现页面访问错误 由于数据库连接timeout产生5XX错误 由于慢查询造成页面无法加载 由于阻塞造成数据无法提交 增加数据库的稳定性 很多数据库的问题都是由于低效查询引起的 优化用户体验 流畅页面的访问速度 良好的网站功能体验 可以从以下几个方面进行数据库优化 MySQL数据库优化: 1.SQL语句优化 2.有效的索引 3.数据库的表结构 4.Linux系统配置优化:打开的文件数等 5.硬件:更加适合数据库系统的cpu、更快的io:ssd等、更多的内存... 2-1数据准备 Sakila样本数据库介绍 下载Sakila样本数据库,下载地址http://downloads.mysql.com/docs/sakila-db.tar.gz(下载页面http://dev.mysql.com/doc/index-other.html)。 导入sakila-schema.sql和sakila-data.sql文件 首先下载mysql5. 7 .18 zip安装包,配置环境变量 bin文件夹下建立my.ini [ mysqld ] basedir = E:\Program Files (x86)\mysql - 5.7 . 24 - winx64\mysql - 5.7 . 24 - winx64\bin datadir =

using guice injection with actor throws null pointer

大兔子大兔子 提交于 2019-12-01 04:49:44
I'm getting null pointer exception on the field injection of a server which is started as an akka actor. Schedular part: private ActorRef myActor = Akka.system().actorOf( new Props(Retreiver.class)); @Override public void onStart(Application app) { log.info("Starting schedular.....!"); Akka.system() .scheduler() .schedule(Duration.create(0, TimeUnit.MILLISECONDS), Duration.create(30, TimeUnit.MINUTES), myActor, "tick", Akka.system().dispatcher()); } Retreiver class part: public class Retreiver extends UntypedActor { private Logger.ALogger log = Logger.of(Retreiver .class); @Inject private

Best method to peek into a Scala Actor's Mailbox

≯℡__Kan透↙ 提交于 2019-12-01 04:27:06
Using Scala 2.8 RC1 or newer, what is the best (easiest and/or most direct) method to "peek" at the waiting messages in an actor's mailbox (from within the same actor's act() method) in order to examine what is in the queue, without having to react/receive the messages and/or disturb the current contents of the mailbox in any way. The purpose of this is so that an actor may determine if it is safe to process a request to exit by first determining if any of the remaining mailbox messages are ones that must be processed, instead of just dropped by stopping the actor immediately. You don't need

How can I use Akka Actors in a Java application?

旧街凉风 提交于 2019-12-01 04:02:54
问题 I would like to use Akka actors in Java. I downloaded the akka-1.0.zip and added akka-actor-1.0.jar to my "Build Path" in Eclipse. Then I wrote this Actor class: package com.example; import akka.actor.UntypedActor; public class MyActor extends UntypedActor { public void onReceive(Object message) throws IllegalArgumentException { if (message instanceof String) { System.out.println("Received: " + message); } else throw new IllegalArgumentException("Unknown message: " + message); } } But I get

How can I host multiple Service Fabric Actor Types inside a single service?

扶醉桌前 提交于 2019-12-01 03:49:06
I've read here that is should be possible to host tightly coupled ActorTypes within the same service but I can't seem to find any documentation on exactly how to do it. I thought it might I need to create my own instance of the ActorService and pass the context into it but I don't seen to be able to find the right API's from the document. Does anyone have an example they could share ? Sort of but not really. You can have multiple actor types in the same application . It looks like they're in the same service in Visual Studio, but they're actually deployed as separate services. Bear with me for

Akka actor logging not writing to file

南笙酒味 提交于 2019-11-30 18:45:23
I'm attempting to log to a file rather than stdout. My application.conf (in src/main/resources/): akka { event-handlers = ["akka.event.slf4j.Slf4jEventHandler"] loglevel = "DEBUG" } logback.xml (in src/main/resources/): <configuration> <appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>log/app.log</file> <append>true</append> <encoder> <pattern>%date{yyyy-MM-dd} %X{akkaTimestamp} %-5level[%thread] %logger{1} - %msg%n</pattern> </encoder> </appender> <root level="DEBUG"> <appender-ref ref="FILE"/> </root> </configuration> Creating the actor system: val conf: Config =

Get existing or create new akka actor

大城市里の小女人 提交于 2019-11-30 14:14:37
问题 I'm trying to get an existing ActorRef with ActorFor or create a new one if it does not exists. I have the following code but it doesn't seem to work as expected. .isTerminated() is always true. ActorSystem system = ActorSystem.create("System"); ActorRef subscriberCandidate = system.actorFor("akka://System/user/"+name); if (subscriberCandidate.isTerminated()) { ActorRef subscriber = system.actorOf(new Props(new UntypedActorFactory() { public UntypedActor create() { return new Sub(name,link);

“Dead Letters encountered” error while running AKKA remote actors

陌路散爱 提交于 2019-11-30 14:09:14
问题 I am trying to run remote actors using AKKA, on my localhost, but each time I get this error. It says dead letters encountered. I searched on internet and found out that this error comes when actors receive a message after its thread is stopped. So I am looking for a way to keep the actors alive on remote machines. I am using akka actors and not the scala actors. [INFO] [09/16/2013 18:44:51.426] [run-main] [Remoting] Starting remoting [INFO] [09/16/2013 18:44:51.688] [run-main] [Remoting]

Should my Scala actors' properties be marked @volatile?

左心房为你撑大大i 提交于 2019-11-30 13:56:20
In Scala, if I have a simple class as follows: val calc = actor { var sum = 0 loop { react { case Add(n) => sum += n case RequestSum => sender ! sum } } } Should my field sum be marked @volatile ? Whilst the actor is logically single-threaded (i.e. the messages are processed sequentially), the individual reactions may be happening on separate threads and hence the state variable may be being altered on one thread and then read from another. You don't need to mark them as volatile. The execution of your code isn't inside a synchronized block, but the actor will always pass through one before