akka java api helloworld

Akka Java API 2.5 参考手册 Akka is a toolkit and runtime for building highly concurrent, distributed, and resilient message-driven applications on the JVM. 立即下载
package com.usoft;
 
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UntypedActor;
 
/**
 * Created by liyanxin on 2015/1/8.
 */
public class HelloWorld {
 
    /**
     * 在这里实现这样一个功能,A actor给 B actor 发送消息,接收后返回消息说已收到
     */
    public static class A extends UntypedActor {
        @Override
        public void preStart() throws Exception {
 
            // 使用当前actor的context 创建了一个子actor,B actor就是A actor的子actor
            // using an actor’s context will create a child actor
            final ActorRef child =
                    getContext().actorOf(Props.create(B.class), "myChild");
            child.tell("good moring", this.getSelf());
        }
 
        @Override
        public void onReceive(Object message) throws Exception {
            if (message instanceof String) {
                System.out.println("接收到B Actor的消息:" + message);
                getContext().stop(getSelf());
            }
        }
    }
 
    public static class B extends UntypedActor {
        @Override
        public void onReceive(Object message) throws Exception {
            if (message instanceof String) {
                System.out.println("接收到A Actor的消息:" + message);
                this.getSender().tell("thank you!", this.getSelf());
            }
        }
    }
 
 
    public static void main(String args[]) {
 
        ActorSystem system = ActorSystem.create("myActorSystem");
 
        // Actors are created by passing a Props instance into the actorOf factory method which is available on
        // ActorSystem and ActorContext.
        // 通过ActorSystem 和 ActorContext的工场方法actorOf创建actor
        // 工场方法需要接收一个Props instance
        system.actorOf(Props.create(A.class), "helloWorld");
    }
}
akka-actor_2.11 jar包 立即下载

相关推荐

IGV新手必看:5分钟搞定ChIP-seq/DAP-seq/ATAC-seq数据可视化(附常见报错解决方案)

本文为IGV新手提供了一份快速上手的实战指南,详细讲解了如何高效完成ChIP-seq、DAP-seq、ATAC-seq等数据的可视化。内容涵盖软件安装、基因组导入、文件格式转换与优化,并重点剖析了“导入后一片空白”等常见报错的根本原因与解决方案,帮助用户在5分钟内避开雷区,生成可用于发表的IGV专业图谱。

weixin_29198045的博客 551

Akka学习指南(Java版)——2.初识事件驱动API

在继续学习更复杂的基于 Actor 的应用程序之前,需要了解一些事件驱动编程模型中的基本抽象概念:Promise和 Future。在前文中,我们已经了解过如何向一个 Actor 发送消息,以及如何在 Actor 内根据接收到的事件进行不同的响应行为。 但是,如果想要通过发送消息向 Actor 请求获取一些输出结果呢?比如说需要从内存键值存储中获取一条记录。 1. 常见阻塞式 IO 案例 几乎每个开发者都很熟悉阻塞式的代码。进行 IO 操作时,编写的都是阻塞式的代码。当我们调用一个同步的 API 时,调用的方

代码时光 597

智能车竞赛飞檐走壁组赛道制作全攻略:从电磁线铺设到立体元素搭建

本文提供了智能车竞赛飞檐走壁组赛道制作的完整指南。从电磁线选材、电流控制与精准铺设等基础入手,详细解析了垂直墙面、圆筒、跷跷板等核心立体元素的构建技巧与过渡处理。重点分享了确保赛道稳定、符合规则且便于调试的实战经验,帮助参赛队伍搭建可靠的立体赛道,为车模算法调试奠定坚实基础。

weixin_29292535的博客 1324

《Java高并发程序设计》学习 --7.1 Akka之Hello World

首先看一下,第一个Actor的实现: public class Greeter extends UntypedActor { public static enum Msg { GREET,DONE; } @Override public void onReceive(Object msg) throws Exception { if(msg ==Msg.GREET) { S

sunhaoning的专栏 2564

新手小白如何学习编程

学习目标推荐第一门语言优势网站 / APP 开发(前端)JavaScript浏览器原生支持,能快速做出可视化效果后端 / 服务器 / 数据分析Python语法简洁像英语,库多、应用广(入门友好)游戏开发先用电竞入门,再转专业引擎硬件 / 嵌入式(比如单片机)C 语言贴近硬件,行业标准办公自动化(Excel / 文档处理)Python快速解决重复工作(比如批量改文件)👉新手首选推荐。

2501_94331842的博客 2237

使用VNC可视化Docker容器

Docker容器可视化

Robert_Q的博客 1万+

Akka学习笔记-简介与API简单操作

Akka 是一个用 Scala 编写的库,用于简化编写容错的、高可伸缩性的 Java 和 Scala 的 Actor 模型应用。Akka是一个开发库和运行环境,可以用于构建高并发、分布式、可容错、事件驱动的基于JVM的应用。使构建高并发的分布式应用更加容易。

PURSUE ONE PIECE 2062

武汉理工大学 python实验三

请编一个程序,用户在同一行内输入两个整数,代表头和脚的数量,编程计算笼中各有多少只鸡和兔(假设鸡和兔都正常,无残疾),如无解则输出`“Data Error!题目为:今有物不知其数,三三数之剩二,五五数之剩三,七七数之剩二,问物几何?年前,《孙子算经》中记载一个有趣的问题:今有雉兔同笼,上有三十五头,下有九十四足,问雉兔各几何?有一座八层宝塔,每一层都有一些琉璃灯,每一层的灯数都是上一层的二倍,已知共有。编写一个宝塔上的琉璃灯的小程序,计算并输出每层各有多少盏琉璃灯。,如果有多个解,则分行输出,每行一个解;

2401_83472225的博客 5958

akka java quick start_Akka Quickstart with Java-笔记

官方文档: http://developer.lightbend.com/guides/akka-quickstart-java/?_ga=2.177525157.1012573474.1504767665-546319647.1504766934一. AKKA Hello World example :1.首先需要创建一个ActorSystem, 它是所有Actor运行的容器.2.其次创建Gre...

weixin_31509753的博客 150

零基础玩转华为AP 4050DN-HD:FAT模式家庭无线网络配置实战

本文为零基础用户提供华为AP 4050DN-HD从FIT模式转换为FAT模式的完整实战教程。详细介绍了固件升级、模式转换以及配置家庭无线网络(包括路由、DHCP、Wi-Fi和NAT)的每一步操作,帮助用户将企业级瘦AP改造为高性能家庭胖AP,打造稳定可靠的家庭网络环境。

weixin_29196613的博客 646

PyTorch实战:3D U-Net医学图像分割从零搭建(附完整代码)

本文详细介绍了如何使用PyTorch从零搭建3D U-Net模型进行医学图像分割,涵盖三维卷积实现、模块化架构设计、医学图像专属优化策略及完整训练流程。通过实战代码演示,帮助开发者掌握UNet-3D在CT、MRI等三维医学图像分割中的应用,提升肝脏肿瘤分割、肺结节检测等任务的准确性。

weixin_29061997的博客 336

akka java quick start_Akka Quickstart with Java-笔记(示例代码)

官方文档: http://developer.lightbend.com/guides/akka-quickstart-java/?_ga=2.177525157.1012573474.1504767665-546319647.1504766934一. AKKA Hello World example :1.首先需要创建一个ActorSystem, 它是所有Actor运行的容器.2.其次创建Gre...

weixin_39524574的博客 144

leetcode134 加油站

题目如下 在一条环路上有 N 个加油站,其中第 i 个加油站有汽油 gas[i] 升。 你有一辆油箱容量无限的的汽车,从第 i 个加油站开往第 i+1 个加油站需要消耗汽油 cost[i] 升。你从其中的一个加油站出发,开始时油箱为空。 如果你可以绕环路行驶一周,则返回出发时加油站的编号,否则返回 -1。 说明: 如果题目有解,该答案即为唯一答案。 输入数组均为非空数组,且长度相同。 输...

ayang818 's blog 238

akka---actor模型

本文转载自:http://www.blogbus.com/public/tb.php/4212/235916459/d5b305d875fff7ba454c396085a01156 只要稍微了解过一些Scala,这门JVM上广受关注的程序设计语言,你一定会对其中的一个Actor特性印象深刻。Actor是另一种进行并发计算的方式。通过在不同的Actor之间彼此发送消息,我们会惊喜地发现,那令人纠结

熊猫的专栏 543

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

Hello,Akka

版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明http://www.blogbus.com/dreamhead-logs/235916459.html 只要稍微了解过一些Scala,这门JVM上广受关注的程序设计语言,你一定会对其中的一个Actor特性印象深刻。Actor是另一种进行并发计算的方式。通过在不同的Actor之间彼此发送消息,我们会惊喜地发现,那令人纠结的锁将不再困...

weixin_34032792的博客 93

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Akka构建Reactive应用《one》

 看到这Akka的官网,描述使用java或者scala构建响应式,并发和分布式应用更加简单,听着很高级的样子,下面的小字写着消息驱动,但是在quickstart里面又写容错事件驱动,就是这么钻牛角尖。     Actors是的Akka的执行单位,Actor模型是一个抽象概念,它使得编写并发的、并行的和分布式的系统变得更加容易。官方给了一个 “helloworld” 示例,演示了基本知识,我们...

woshiyexinjie的专栏 447

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

actor 模型 锁 java_漫谈并发编程:Actor模型

0x00 前言一般来说有两种策略用来在并发线程中进行通信:共享数据和消息传递。熟悉c和java并发编程的都会比较熟悉共享数据的策略,比如java程序员就会常用到 java.util.concurrent 包中同步、锁相关的数据结构。使用共享数据方式的并发编程面临的最大的一个问题就是数据条件竞争(data race)。处理各种锁的问题是让人十分头痛的一件事。和共享数据方式相比,消息传递机制最大的优点...

weixin_28595749的博客 768

漫谈并发编程:Actor模型

0x00 前言 文章结构 0x01 基本概念 什么是Actor模型 消息和信箱 0x02 Akka中的Actor Actor System Actor的层级 Actor的生命周期 0x03 例子 1. HelloWorld 简单版 2. HelloWorld 升级版 3. 伪分布式 WordCount 0x04 总结 参考 0x00 前...

maso88的专栏 900

并发:Actor模型。

前言 一般来说有两种策略用来在并发线程中进行通信:共享数据和消息传递。熟悉c和java并发编程的都会比较熟悉共享数据的策略,比如java程序员就会常用到java.util.concurrent包中同步、锁相关的数据结构。 使用共享数据方式的并发编程面临的最大的一个问题就是数据条件竞争(data race)。处理各种锁的问题是让人十分头痛的一件事。 和共享数据方式相比,消息传递机制最大的优点...

孤芳不自赏 603

Netty3学习笔记(二) --- Netty Helloworld入门

netty可以运用在那些领域? 1 分布式进程通信 例如: hadoop、dubbo、akka等具有分布式功能的框架,底层RPC通信都是基于netty实现的,这些框架使用的版本通常都还在用netty3.x 2、游戏服务器开发 最新的游戏服务器有部分公司可能已经开始采用netty4.x 或 netty5.x 3、netty服务端hello world案例 SimpleChannelHandler 处...

小道的博客 316

Vert.x简介、原理与HelloWorld

Vert.x 简介 官方文档 http://vertx.io/docs/vertx-core/java/ 关于Vert.x Vertx,是一个基于JVM、轻量级、高性能的应用平台,非常适用于移动端后台、互联网、企业应用架构。 Vertx,基于Netty全异步通信,并扩展出了很多有用的特性。 Vertx,是基于事件总线设计的高性能架构,保证应用中不同部分以一种非堵塞的线程安全方式通讯。 Vertx,是借鉴Erlang和Akka架构设计,能充分利用多核处理器性能并实现高并发编程需求的框架。 Vert.x特点 支

Baldwin_KeepMind 4711

scala介绍,编写一个hello world程序

Scala是一种现代的、多范式的编程语言,其设计目的是为了简洁、优雅,同时保持与Java的兼容性。Scala是"scalable language"的缩写,这也意味着它是一个可以应对各种规模应用的语言,从小型脚本到大型系统。以下是Scala的一些关键特点和优点:静态类型:尽管Scala有静态类型系统,但许多类型信息都可以从上下文中推导出来,使得代码既安全又简洁。函数式编程:Scala是一种纯粹的面向对象语言,但它同时也支持函数式编程范式。

906
上一篇: 流计算容错
下一篇: flink akka
codemosi
博客等级 码龄15年 70粉丝 90原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值