简体   繁体   English

Java Web应用程序之间的通信

[英]Communication between Java web applications

I have multiple Java web applications deployed on the same server (Wildfly). 我在同一台服务器(Wildfly)上部署了多个Java Web应用程序。

They all should use a single WebSocket implementation to send messages (object, not plain text) to the user. 他们都应该使用单个WebSocket实现向用户发送消息(对象,而不是纯文本)。

Edit: WebApp1-3 are the applications with the business logic. 编辑: WebApp1-3是具有业务逻辑的应用程序。 The only purpose of WebApp4 is to update a Primefaces panel in the browser based on the messages generated by the other WebApps. WebApp4的唯一目的是根据其他WebApp生成的消息来更新浏览器中的Primefaces面板。 Sorry for the missleading illustration. 对不起,误导性插图。

WebApp1
WebApp2    -->    ???    -->   WebApp4 (WebSocket-Server)   -->    JS/Browser
WebApp3

Which is the best way/pattern/implementation to make WebApp4 available to the other applications? 使WebApp4可用于其他应用程序的最佳方法/模式/实现是哪一种? (RMI, JMS, WebSocket, WebService, ....?) (RMI,JMS,WebSocket,WebService等)。

My advice, for a general way of exposing services, is to expose REST services since they are simpler than SOAP web service and easily allow interoperability (if in the future a PHP or a RUBY webapp needs to consume your services it's much easier with a REST interface than with one base on RMI or JMS). 对于一般公开服务的方式,我的建议是公开REST服务,因为它们比SOAP Web服务更简单并且易于实现互操作性(如果将来PHP或RUBY Web应用程序需要使用您的服务,那么使用REST会更容易接口,而不是基于RMI或JMS的接口)。 The content of the REST service may vary, I suggest you to look at XML or JSON as a way of transmitting information over http REST services. REST服务的内容可能有所不同,我建议您将XML或JSON视为通过http REST服务传输信息的一种方式。

If all webapps are in the same server, you should forward requests from one to another. 如果所有Web应用程序都在同一服务器上,则应请求从一个转发到另一个。 From the point of view of webapps 1-3, they would not need to be aware of whether their incoming requests were coming from webapp 4 or from outside (to which it appears that they are not connected). 从webapps 1-3的角度来看,他们不需要知道他们的传入请求是来自webapp 4还是来自外部(似乎未连接到外部)。 Of course, you are free to alter requests before forwarding them - or to drop them altogether, for example if authentication fails. 当然,您可以自由地在转发请求之前更改请求,也可以将其完全删除,例如,如果身份验证失败。

To do this in tomcat: https://stackoverflow.com/a/8951090/15472 要在tomcat中执行此操作: https : //stackoverflow.com/a/8951090/15472

When forwarding requests, the external client is completely unaware of the existence of webapps 1-3 -- as far as the client is concerned, it has sent a request to webapp 4, and it will think it is receiving a response from that same server. 在转发请求时,外部客户端完全不知道webapps 1-3的存在-就客户端而言,它已经向webapp 4发送了一个请求,并且会认为它正在接收来自同一服务器的响应。

You may need to configure your web server to allow these kinds of calls, but I am unfamiliar with WildFly. 您可能需要将Web服务器配置为允许此类呼叫,但是我对WildFly并不熟悉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Websockets在两个JAVA Web应用程序之间进行通信 - communication between two JAVA web applications using Websockets Weblogic集群中Web应用程序之间的通信 - Communication between web applications in a weblogic cluster Java和C#应用程序之间的SSL通信 - SSL communication between Java and C# applications java spring 服务器和 python 应用程序之间的通信 - Communication between java spring server and python applications 两个独立的 Java 桌面应用程序之间的通信 - Communication between two separate Java desktop applications Java库:2个或更多Java应用程序之间的套接字通信 - java library: socket communication between 2 or more java applications cacerts文件在两个Web应用程序之间进行通信的作用 - Role of cacerts file communication between two web applications 两个应用程序之间的原始套接字通信(在C中使用一个,在Java中之一在使用中) - raw socket communication between two applications one in c and one in java 2个Tomcat实例-2个应用程序之间的通信 - 2 Tomcat Instances - Communication between 2 applications Java Web应用程序与Web服务之间的线程间通信 - inter thread communication between java web application and web service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM