在相同EAR之间的WAR之间进行沟通的选项 [英] Options to communicate between WARs in the same EAR

查看:96
本文介绍了在相同EAR之间的WAR之间进行沟通的选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你有什么选择在EAR中的战争之间沟通?
我们有几个WAR在一个EAR内部署了不同的Web服务。对于他们的任务,他们需要与其他战争通信。当然,他们可以使用webservices进行通信。还有哪些其他可能更有效的选择?



编辑:通信的原因是模块使用一些共享功能,我们希望将此功能定位在只有一个地方,因为它需要大量的资源。此外,这需要同步通信。

解决方案

首先,你应该清楚你正在分享什么。您应该区分服务和图书馆。
库可以让您共享通用功能,这是您在使用log4j库时实现的。在这种情况下,您在使用它的每个项目中设置log4j。
另一方面,您可以使集中式日志记录服务具有自己的日志记录配置,并允许您在一个地方进行管理。在这种情况下,您需要共享服务。



您可以通过将jar放入每个战争或耳朵内部来共享库。
您可以通过服务客户端共享服务。因此,您的Web服务可以使用其他服务。在这种情况下,一个Web服务是另一个Web服务的客户端,实现服务组合(企业开发中的常见模式)



如果服务客户端和服务本身都位于同一个耳朵,比您可以通过直接调用服务来避免一些开销,例如使用Spring的父上下文功能:
http://springtips.blogspot.com/2007/06/using-shared-parent-application-context.html
但是,我建议不要对服务进行平整,因为您将失去首先提供服务的不同优势,例如治理,可管理性等。


What options do you have to communicate between the WARs in an EAR? We have several WARs providing different webservices deployed within one EAR. For their tasks they need to communicate with the other WARs. Of course they could communicate using webservices. What other, perhaps more efficient, options are there?

EDIT: The reason for the communication is that the modules use some shared functionality, and we want to locate this functionality in only one place, since it requires a significant amount of resources. Also, this requires synchronous communication.

解决方案

First, you should be clear about what is that you are sharing. You should differentiate between the service and a library. Library lets you share the common functionality, this is what you achieve when you use log4j library for example. In that case, you setup log4j in each project that is using it. On the other hand, you could have the centralized logging service that has its own logging configuration and lets you manage this in a single place. In this case, you need to share the service.

You can share the library by placing the jar inside each war or inside the ear. You can share the service by being the service client. So, your web services can use another service. In that case, one web service is a client of another, achieving service composition (a common pattern in enterprise development)

If both service client and service itself reside inside the same ear, than you might avoid some overhead by calling the service "directly", for example using the Spring’s parent context feature: http://springtips.blogspot.com/2007/06/using-shared-parent-application-context.html but I would advise against flattening the service because you will loose different benefits that having service in the first place provides like governance, manageability etc.

这篇关于在相同EAR之间的WAR之间进行沟通的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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