rpc

code after Gwt rpc AsyncCallbak will not be executed?

混江龙づ霸主 提交于 2019-12-02 05:16:20
I can't understand why the code after the gwt rpc AsyncCallback will not be executed? for example I have the interface AppService extends RemoteService, So I'll have AsyncAppService which does the async call. the following code AppServiceAsync service = GWT.create (AppService.class); service.getCurrentUser(new AsyncCallback<Employee>(){ public void onFailure(Throwable caught) { } public void onSuccess(Employee result) { currentUser = result; } }); // if i have the code after the above call, these code will not be execute, what is the problem //code following will not be executed if they are in

gwt java.lang.ExceptionInInitializerError

两盒软妹~` 提交于 2019-12-02 04:19:42
I'm working on a GWT app, and keep getting the error shown below. I followed the GWT tutorial regarding naming conventions for servlet classes, and followed the Service / Async / ServiceImpl structure. I also tried adding the -XX:-UseSplitVerifier VM argument to fix a previous problem. any ideas on what's going on? SEVERE: javax.servlet.ServletContext log: Exception while dispatching incoming RPC call java.lang.ExceptionInInitializerError at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun

java实现RPC

北慕城南 提交于 2019-12-02 01:43:44
一,服务提供者 工程为battercake-provider,项目结构图如下图所示 1.1 先创建一个“卖煎饼”微服务的接口和实现类 package com.jp.service; public interface BatterCakeService { /** * 卖煎饼的服务 */ public String sellBatterCake(String name); } package com.jp.service; import com.jp.service.BatterCakeService; /** * 卖煎饼服务的实现类 * */ public class BatterCakeServiceImpl implements BatterCakeService { public String sellBatterCake(String name) { return name+"煎饼,卖的特别好"; } } 1.2 RPC框架调用部分 该部分有两个关键部分: RPC服务提供器 和 线程处理类 1) RPC服务提供器 将 需要发布的服务 存储在一个内存变量serviceList中。( 该例就是把卖煎饼服务的实例对象传入 ) 启动socket,server.accept()方法阻塞在那,监听输入 针对每一个请求,单独启动一个线程处理 1 package com.jp.rpc; 2

SSL certificate problem in a web service proxy

大憨熊 提交于 2019-12-02 01:05:35
I am building a JAVA web service client in which i connect to a service. This service has a ssl certificate verification. How to call this service using ssl certificate verification. I am using JAX-RPC implementation in client built using Eclipse. An example would be appriciated. Raj I am able to do the web service connection... I added the key store using the command: keytool -import -trustcacerts -file <file path/filename.cer> -alias <aliasName> -keystore <JAVA_HOME/jre/lib/security/cacerts> gave the password as "changeit" and added the certificate in keystore. Now in code i added two lines:

从零开始手写 dubbo rpc 框架

荒凉一梦 提交于 2019-12-02 00:05:27
rpc rpc 是基于 netty 实现的 java rpc 框架,类似于 dubbo。 主要用于个人学习,由渐入深,理解 rpc 的底层实现原理。 前言 工作至今,接触 rpc 框架已经有很长时间。 但是对于其原理一直只是知道个大概,从来没有深入学习过。 以前一直想写,但由于各种原因被耽搁。 技术准备 Java 并发实战学习 TCP/IP 协议学习笔记 Netty 权威指南学习 这些技术的准备阶段,花费了比较长的时间。 也建议想写 rpc 框架的有相关的知识储备。 其他 rpc 框架使用的经验此处不再赘述。 快速迭代 原来一直想写 rpc,却不行动的原因就是想的太多,做的太少。 想一下把全部写完,结果就是啥都没写。 所以本次的开发,每个代码分支做的事情实际很少,只做一个功能点。 陆陆续续经过近一个月的完善,对 rpc 框架有了自己的体会和进一步的认知。 代码实现功能,主要参考 Apache Dubbo 文档 文档 文档将使用 markdown 文本的形式,补充 code 层面没有的东西。 代码注释 代码有详细的注释,便于阅读和后期维护。 测试 目前测试代码算不上完善。后续将陆续补全。 rpc 模块 rpc-common 公共代码 rpc-server 服务端 rpc-client 客户端 rpc-register 注册中心 rpc-test 测试模块 代码分支 release_0

RPC的解释

大城市里の小女人 提交于 2019-12-01 22:48:23
如何科学的解释RPC 说起RPC,就不能不提到分布式,这个促使RPC诞生的领域。 假设你有一个计算器接口,Calculator,以及它的实现类CalculatorImpl,那么在系统还是单体应用时,你要调用Calculator的add方法来执行一个加运算,直接new一个CalculatorImpl,然后调用add方法就行了,这其实就是非常普通的本地函数调用,因为在同一个地址空间,或者说在同一块内存,所以通过方法栈和参数栈就可以实现。 现在,基于高性能和高可靠等因素的考虑,你决定将系统改造为分布式应用,将很多可以共享的功能都单独拎出来,比如上面说到的计算器,你单独把它放到一个服务里头,让别的服务去调用它。 这下问题来了,服务A里头并没有CalculatorImpl这个类,那它要怎样调用服务B的CalculatorImpl的add方法呢? 有同学会说,可以模仿B/S架构的调用方式呀,在B服务暴露一个Restful接口,然后A服务通过调用这个Restful接口来间接调用CalculatorImpl的add方法。 很好,这已经很接近RPC了,不过如果是这样,那每次调用时,是不是都需要写一串发起http请求的代码呢?比如httpClient.sendRequest...之类的,能不能像本地调用一样,去发起远程调用,让使用者感知不到远程调用的过程呢,像这样: @Reference

RPC原理及RPC实例分析

本小妞迷上赌 提交于 2019-12-01 21:55:25
在学校期间大家都写过不少程序,比如写个hello world服务类,然后本地调用下,如下所示。这些程序的特点是服务消费方和服务提供方是本地调用关系。 public class Test { public static void main(String[] args) { HelloWorldService helloWorldService = new HelloWorldServiceImpl(); helloWorldService.sayHello("test"); } } 而一旦踏入公司尤其是大型互联网公司就会发现,公司的系统都由成千上万大大小小的服务组成,各服务部署在不同的机器上,由不同的团队负责。 这时就会遇到两个问题: 要搭建一个新服务,免不了需要依赖他人的服务,而现在他人的服务都在远端,怎么调用? 其它团队要使用我们的新服务,我们的服务该怎么发布以便他人调用?下文将对这两个问题展开探讨。 1. 如何调用他人的远程服务? 由于各服务部署在不同机器,服务间的调用免不了网络通信过程,服务消费方每调用一个服务都要写一坨网络通信相关的代码,不仅复杂而且极易出错。 如果有一种方式能让我们像调用本地服务一样调用远程服务,而让调用者对网络通信这些细节透明,那么将大大提高生产力,比如服务消费方在执行helloWorldService.sayHello("test")时

Golang通过Thrift框架完美实现跨语言调用

*爱你&永不变心* 提交于 2019-12-01 21:52:20
  每种语言都有自己最擅长的领域,Golang 最适合的领域就是服务器端程序。   做为服务器端程序,需要考虑性能同时也要考虑与各种语言之间方便的通讯。采用 http 协议简单,但性能不高。采用 TCP 通讯,则需要考虑封包、解包、粘包等等很多因素,而且想写个高效的 TCP 服务,也很难。   其实,对于此类需求,采用 RPC ( Remote Procedure Call Protocol ) 编程最靠谱。使用 RPC 编程 被认为是在分布式环境中运行的客户机和服务器应用程序之间进行可靠通信的最强大、最高效的方法之一。   Golang 内置了对 RPC 支持,但只能适用于 go 语言程序之间调用,且貌似序列化、反序列化性能不高。如果 go 语言能使用 Thrift 开发,那么就如虎添翼了。可惜, thrift 虽然很早就包含了 golang 的代码,但一直都存在各种问题无法正确执行,以至于GitHub上有许多大牛小牛自行实现的Thrift代码,但依然各种问题……直到 0.9.1 版本的发布!   是的,最近, Apache Thrift 0.9.1 正式发布了。新版的 Thrift 终于对 Golang 提供了完美的支持。经过实验,服务器端、客户端已经完美支持跨语言调用,且性能、尤其是内存占用上,编译型语言的特点展现出来,比 java 版的实现强了很多。   下面,我们采用

RPC can't decode arguments for TCP transport

别说谁变了你拦得住时间么 提交于 2019-12-01 21:02:57
问题 I'm working on a multithreaded RPC server based on the example from this page: http://bderzhavets.blogspot.ca/2005/11/multithreaded-rpc-server-in-white-box.html Unfortunately it didn't quite work out of the box, and after chasing the errors for some time, I've found that the server is failing to decode the arguments (based on the return code from squareproc_2 ). The execution on the server side seems to stop after the call to squareproc_2_svc in the function serv_request . See case:

RPC can't decode arguments for TCP transport

人走茶凉 提交于 2019-12-01 19:58:44
I'm working on a multithreaded RPC server based on the example from this page: http://bderzhavets.blogspot.ca/2005/11/multithreaded-rpc-server-in-white-box.html Unfortunately it didn't quite work out of the box, and after chasing the errors for some time, I've found that the server is failing to decode the arguments (based on the return code from squareproc_2 ). The execution on the server side seems to stop after the call to squareproc_2_svc in the function serv_request . See case: SQUAREPROC in the code below from square_svc.c void *serv_request(void *data) { struct thr_data *ptr_data =