正确的 ZeroMQ 拓扑 [英] RIght ZeroMQ topology

查看:29
本文介绍了正确的 ZeroMQ 拓扑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要编写一个订单管理器,将客户(股票、外汇等)订单发送到适当的交易所.客户想要发送订单,但对 FIX 或其他专有协议一无所知,只知道发送订单的内部(标准化)格式.我有应用程序(服务器),每个应用程序都通过 FIX/Binary/etc 连接连接到每个 FIX/etc 提供程序.我希望在客户端和服务器之间有一个代理程序,该程序采用规范化顺序并将其转换为给定 FIX/etc 提供程序的正确格式,并从服务器获取消息并将其转换回客户端的规范化格式.客户端可以指定路由,但是客户端和服务器之间的代理程序在客户端和服务器之间来回传递有关该订单的消息.因此,必须以某种方式将来自服务器的输出 [填充、部分填充、错误等] 路由回正确的客户端.

I need to write an Order Manager that routes client (stock, FX, whatever) orders to the proper exchange. The clients want to send orders, but know nothing about FIX or other proprietary protocols, only an internal (normalized) format for sending orders. I have applications (servers) that each connect through FIX/Binary/etc connections to each FIX/etc provider. I would like a broker program in between the clients and the servers that take the normalized order and turn it into a proper format to a given FIX/etc provider, and take messages from the servers and turn it back to a normalized format for the clients. It is ok for the clients to specify a route, but it is up to a broker program in between the clients and the servers to communicate messages about that order back and forth between clients and servers. So somehow the output [fills, partial fills, errors, etc] from the server has to be routed back to the right client.

我研究了 ZMQ 拓扑,并且 REQ->ROUTER->DEALER 不起作用 [代码有效 - 我的意思是它是错误的拓扑],因为服务器不相同.

I have studied the ZMQ topologies, and REQ->ROUTER->DEALER doesn't work [the code works - I mean it is the wrong topology] since the servers are not identical.

//This topology doesn't work because the servers are not identical
#include "zhelpers.hpp"

int main (int argc, char *argv[])
{
    // Prepare our context and sockets
    zmq::context_t context(1);
    zmq::socket_t frontend (context, ZMQ_ROUTER);
    zmq::socket_t backend (context, ZMQ_DEALER); // ZMQ_ROUTER here? Can't get it to work

    frontend.bind("tcp://*:5559");
    backend.bind("tcp://*:5560");

    // Start built-in device
    zmq::device (ZMQ_QUEUE, frontend, backend);


    return 0;
}

我认为也许 ROUTER->ROUTER 拓扑是正确的,但我无法使代码工作 - 客户端发送订单但从未收到回复,所以我一定做错了什么.我认为使用 ZMQ_IDENTITY 是正确的做法,但我不仅不能让它工作,而且似乎 ZMQ 正在远离 ZMQ_IDENTITY?

I thought that maybe a ROUTER->ROUTER topology instead is correct, but I can't get the code to work - the clients send orders but never get responses back so I must be doing something wrong. I thought that using ZMQ_IDENTITY is the correct thing to do, but not only can I also not get this to work, but it seems as if ZMQ is moving away from ZMQ_IDENTITY?

有人可以举一个简单的例子来说明三个 ZMQ 程序 [不是在单独的线程中,而是在三个单独的进程中] 来展示正确的方法吗?

Can someone give a simple example of three ZMQ programs [not in separate threads, three separate processes] that show the correct way to do this?

推荐答案

查看指南中的 MajorDomo 示例:http://zguide.zeromq.org/page:all#toc71

Look at the MajorDomo example in the Guide: http://zguide.zeromq.org/page:all#toc71

您需要为每个交换使用一个工作池.

You'd use a worker pool per exchange.

这篇关于正确的 ZeroMQ 拓扑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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