简体   繁体   English

ExpressJS:将事件处理系统公开为 REST 服务 API

[英]ExpressJS: expose Event Processing system as a REST Service API

I am looking for a way to expose an existing event processing system to the external world using a REST interface .我正在寻找一种使用REST interface向外部世界公开现有事件处理系统的方法。 I have existing system design where we have RabbitMQ message queues where a publisher could post a message and then wait for the message processed results on a separate queue.我有现有的系统设计,我们有RabbitMQ消息队列,发布者可以在其中发布消息,然后在单独的队列上等待消息处理结果。 Message ID is used to track the output to the original message on the output queue.消息 ID 用于跟踪输出到输出队列上的原始消息。

提议的设计

Now I want this to be exposed to the external consumers but we don't want to expose our RabbitMQ endpoint for this, so I was wondering if anyone has managed to achieve something similar to this using ExpressJS.现在我希望将其公开给外部消费者,但我们不想为此公开我们的RabbitMQ端点,所以我想知道是否有人设法使用 ExpressJS 实现了与此类似的事情。 Above diagram shows the current thought process上图显示了当前的思考过程

Main challenge I am facing here is that;我在这里面临的主要挑战是; some of this message processing could take more than couple of minutes, so was not sure how best to develop a API like this.有些消息处理可能需要几分钟以上的时间,所以不确定如何最好地开发这样的 API。 Choices like should I create a polling interface for client here or is there a technology these days that help eliminate the polling on the client API to verify if the message is processed and get the result.选择我应该在这里为客户端创建一个轮询接口,还是现在有一种技术可以帮助消除客户端 API 上的轮询,以验证消息是否被处理并获得结果。

Can someone please help me with a good approach to manage these sort of requirement.有人可以帮助我用一种很好的方法来管理这些需求。

I finally ended up going the webhook way.我最终选择了 webhook 方式。 Now when the REST API service receives a request, the client need to also provide a webhook and this will be registered with the client request and server will call it back when the results are available.现在,当 REST API 服务接收到请求时,客户端还需要提供一个 webhook,这将在客户端请求中注册,服务器将在结果可用时回调它。

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

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