简体   繁体   English

Web应用程序中的ZeroMQ用法:前端如何与后端交互

[英]ZeroMQ usage in web application: how frontend interacts with backend

I heard some facts about ZeroMQ, and I think it's very powerful thing. 我听说过有关ZeroMQ的一些事实,我认为这是非常有用的。 But now I try to imagine how it can be applied in web application. 但现在我试着想象它如何应用于Web应用程序。

Could you make an example of using ZeroMQ in web applications? 你能举一个在Web应用程序中使用ZeroMQ的例子吗?

So, the first that strikes me - simple chat application. 所以,第一个打动我 - 简单的聊天应用程序。 So, we need frontend and backend. 所以,我们需要前端和后端。 I prefer using python+Tornado as backend. 我更喜欢使用python + Tornado作为后端。 There is python lib for using ZeroMQ. 使用ZeroMQ有python库。 It's clear. 很明显。 So, the next thing is frontend. 所以,接下来就是前端。 In frontend I will use some javascript to interact with backend. 在前端,我将使用一些JavaScript与后端进行交互。

So, to do this I should use ajax calls, right? 所以,要做到这一点,我应该使用ajax调用,对吧? Are there some other ways to do it? 还有其他方法吗?

TIA! TIA!

The easiest way to do this is to map WebSockets to ZeroMQ sockets, which is quite simple with tornado and PyZMQ's ZMQStream objects. 最简单的方法是将WebSockets映射到ZeroMQ套接字,这对于龙卷风和PyZMQ的ZMQStream对象来说非常简单。 An example of such an app is the IPython Notebook . 这种应用程序的一个例子是IPython Notebook This approach has the downside of requiring websockets, which puts a limit on what browsers you can support. 这种方法的缺点是需要websockets,这限制了您可以支持的浏览器。 Of course, you could also map ajax calls with jQuery, etc. and handle the relay with async handlers in tornado. 当然,您也可以使用jQuery等映射ajax调用,并使用龙卷风中的异步处理程序处理中继。

A more sophisticated web:ZeroMQ app is the mongrel2 webserver. 一个更复杂的网站:ZeroMQ应用程序是mongrel2网络服务器。

The right choice for you is just going to depend on your communication patterns. 正确的选择取决于您的沟通模式。

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

相关问题 如何将不同端口上的前端应用程序与后端连接? - How to connect a frontend application on a different port with a backend? 如何将唯一标识符从我的 express 后端服务器传递到我的前端 reactjs 以显示在我的 web 应用程序中? - How can I pass a unique identifier from my express backend server to my frontend reactjs to be displayed in my web application? 如何将 Web MIDI API 与 React 前端和 Django 后端集成 - How to integrate Web MIDI API with React frontend and Django backend 如何连接前端和后端 - How to Connect Frontend and Backend 如何在本地应用程序中连接前端(js)和后端(php)? - How to connect frontend (js) and backend (php) in a local application? 如何在后端和前端具有不同子文件夹的代码沙箱中运行应用程序 - How to run an application in codesandbox with different subfolder for backend and frontend 前端的AngularJS的后端Web框架角色是什么? - What is the backend web framework role with AngularJS on the frontend? 如何在域上连接前端和后端 - How to connect frontend and backend on domain NodeJS - 如何为后端编写前端? - NodeJS - How to write frontend for backend? 单页应用程序 - 前端独立于后端? - Single Page Application - Frontend independent of backend?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM