Web Services vs EJB vs RMI,优缺点? [英] Web Services vs EJB vs RMI, advantages and disadvantages?

查看:33
本文介绍了Web Services vs EJB vs RMI,优缺点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果所有工作都在那里完成,我的 Web 服务器将很快过载.我要在它后面建立第二台服务器来处理数据.

My web server would be overloaded quickly if all the work were done there. I'm going to stand up a second server behind it, to process data.

EJB 与 RMI 相比有什么优势,反之亦然?

What's the advantage of EJB over RMI, or vice versa?

网络服务(SOAP、REST)怎么样?

What about web services (SOAP, REST)?

推荐答案

EJB 构建在 RMI 之上.两者都意味着 Java 客户端和 bean.如果您的客户端需要使用其他内容(例如 .NET、PHP 等)编写,请使用网络服务或其他使用平台无关的有线协议的内容,例如 HTTP 或 XML over HTTP 或 SOAP.

EJBs are built on top of RMI. Both imply Java clients and beans. If your clients need to be written in something else (e.g., .NET, PHP, etc.) go with web services or something else that speaks a platform-agnostic wire protocol, like HTTP or XML over HTTP or SOAP.

如果选择 RMI,则不需要 Java EE EJB 应用服务器.您必须保持客户端和服务器 JVM 同步;不升级服务器就无法升级客户端.您必须编写 EJB 应用服务器为您提供的所有服务(例如,连接池、命名和目录服务、池、请求队列、事务等).

If you choose RMI, you don't need a Java EE EJB app server. You have to keep client and server JVMs in synch; you can't upgrade the client without upgrading the server. You have to write all the services that the EJB app server provides for you (e.g., connection pooling, naming and directory services, pooling, request queuing, transactions, etc.).

当您考虑时,RMI 是相当低的水平.为什么你会一路回到 CORBA?

RMI is quite low level when you think about it. Why would you drop all the way back to CORBA?

更好的选择是 EJB 3.0 与 Spring.这取决于你是否喜欢 POJO 开发,是否想要选择除 ORM 和 JPA 之外的其他关系技术.

A better choice is EJB 3.0 versus Spring. It depends on whether you like POJO development, want a choice of relational technologies besides ORM and JPA, among other things.

您可以付费购买 Java EE 应用服务器(例如 WebLogic、WebSphere)或使用开源服务器(JBOSS、Glassfish 和 OpenEJB 和 ActiveMQ),或者您可以坚持使用 Spring 并部署在 Tomcat、Jetty、Resin 或任何其他 servlet/JSP 引擎.

You can pay for a Java EE app server (e.g., WebLogic, WebSphere) or use an open source one (JBOSS, Glassfish and OpenEJB and ActiveMQ), or you can stick to Spring and deploy on Tomcat, Jetty, Resin or any other servlet/JSP engine.

Spring 与技术无关,提供了很多选择:持久性(Hibernate、iBatis、JDBC、JDO、JPA、TopLink)、远程处理(HTTP、Hessian、Burlap、RMI、SOAP Web 服务)等.

Spring offers a lot of choice by being technology agnostic: persistence (Hibernate, iBatis, JDBC, JDO, JPA, TopLink), remoting (HTTP, Hessian, Burlap, RMI, SOAP web service), etc.

EJB 3.0 是一个有很多供应商的规范;Spring 只能从 Spring Source 获得.

EJB 3.0 is a spec with many vendors; Spring can only be had from Spring Source.

我会推荐 Spring.它非常坚固,有很大的牵引力,不会去任何地方.它让您的所有选择都保持开放.

I would recommend Spring. It's very solid, has lots of traction, isn't going anywhere. It leaves all your options open.

Web 服务在理论上很棒,但您需要注意一些问题:

Web services are great in theory, but there are some gotchas that you need to watch out for:

  1. 延迟.福勒分布式对象第一定律:不要!"由大量细粒度分布式 SOAP 服务组成的体系结构将优雅、美观且缓慢.分发前请仔细考虑.
  2. 从 XML 到对象再到对象的编组会消耗 CPU 周期,除了允许您的客户使用与平台无关的协议之外,这些周期不会提供任何商业价值.
  3. SOAP 是一个每天都变得越来越臃肿和复杂的标准,但它有很多工具支持.供应商喜欢它,因为它有助于推动 ESB 的销售.REST 很简单,但不是很容易理解.工具不支持它.

Spring 的 web 服务模块非常好,但是选择这种方式部署时要小心.根据 POJO 服务接口来编写.这些将使您能够获得所需的概念隔离,将部署选择推迟到最后一刻,并让您在第一个想法表现不佳时改变主意.

Spring's web service module is very good, but do be careful about choosing to deploy this way. Write in terms of POJO service interfaces. These will allow you to get the conceptual isolation you want, defer the deployment choice until the last moment, and let you change your mind if the first thought doesn't perform well.

这篇关于Web Services vs EJB vs RMI,优缺点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆