简体   繁体   English

Cloud Foundry中的App to App通信

[英]App to App communication in Cloud Foundry

Assume you want to deploy 2 apps of which one provides some API to the second application. 假设您要部署2个应用程序,其中一个应用程序为第二个应用程序提供了一些API。

With services I'd just bind the service (or declare it as dependency in my manifest) to my application and hence get the information regarding host, port and credentials passed to my application (eg via env variables in node.js). 使用服务,我只是将服务绑定(或将其声明为我的清单中的依赖关系)到我的应用程序,从而获得有关传递给我的应用程序的主机,端口和凭证的信息(例如,通过node.js中的env变量)。 Is there a similiar mechanism for application to application "communication"? 应用程序“通信”是否有类似的机制?

So far my approach is to use a RabbitMQ service (or any message broker/queue) which both applications are bound to and which I then use for cross-app communication. 到目前为止,我的方法是使用两个应用程序绑定的RabbitMQ服务(或任何消息代理/队列),然后将其用于跨应用程序通信。

Thanks! 谢谢!

From your use case, for microservice to microservice discovery, you need Spring Cloud Services and Eureka. 从您的用例,从微服务到微服务发现,您需要Spring Cloud Services和Eureka。

I don't have much experience on nodejs. 我对nodejs没有多少经验。 But some googling, will give you some articles. 但是一些谷歌搜索,会给你一些文章。 Here's one that may help you - https://www.npmjs.com/package/eureka-js-client 这是一个可以帮助你的方法 - https://www.npmjs.com/package/eureka-js-client

This article will give you an overview from Java and Spring perspective - https://spring.io/guides/gs/service-registration-and-discovery/ . 本文将从Java和Spring的角度概述 - https://spring.io/guides/gs/service-registration-and-discovery/

Using a message broker, as you do, is definitely a viable solution. 像你一样使用消息代理绝对是一个可行的解决方案。 This allows for asynchronous communication. 这允许异步通信。 Yet you will have to take care of authentication yourself, as opposed to app <-> service communication, where authentication/authorization is established through through cloudfoundry service binding. 然而,您必须自己处理身份验证,而不是app < - >服务通信,其中通过cloudfoundry服务绑定建立身份验证/授权。

Another way would be to use a service registry for this. 另一种方法是使用服务注册表。 Both apps would register with the service registry and be able to discover each other. 这两个应用程序都将注册到服务注册表,并能够相互发现。

You could try spring cloud service registry (Eureka) or consul. 您可以尝试Spring云服务注册表(Eureka)或领事。 As for your message broker solution, this will not generate credentials for your apps, as a cloudfoundry service binding does. 至于您的消息代理解决方案,这不会为您的应用生成凭据,就像cloudfoundry服务绑定一样。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM