ZeroMQ Round Robin Connect

时间:2015-06-12 10:18:24

标签: zeromq

我一直在尝试使用ZeroMQ中的示例和示例来构建分布式MQ系统。

我们是否可以创建连接的循环(不是发出的消息):

{
...
...
  zmq::context_t context (1);
  zmq::socket_t subscriber (context, ZMQ_SUB);
  int rc = subscriber.connect("tcp://primary_host:5556");
  // I don't want to do this till the first one fails! 
  // int rc1 = subscriber.connect("tcp://failover_host:5557");
...
}

我想象我的代码理想情况下会是这样的 -

{
... 
... 
std::vector<std::string> urls = SomeServiceRegistry.getMeMessageServerUrls("SomeTopics_OR_FILTERS"); 

   zmq::context_t context (1);
   zmq::socket_t subscriber (context, ZMQ_SUB);

   // I would expect this guy to essentially - 
   // handle - disconnects, and pick up and connect 
   // to the next one in the vector, eventually, rolling back to the 0th index.
   zmq::connect_round_robin(urls);
...  
}

想知道是否有预先构建的模式功能来实现这一目标。找不到任何东西。如果我错过任何事情,很高兴得到纠正(......或抨击!)以下是我想要实现的目标 -

  1. PUB处于多个冗余实例中。所有人都做同样的事情。 (我们现在不担心PUB之间的同步)
  2. SUB不需要建立多个连接/套接字 - 我不想为可能不使用的东西付费。 PUB可能永远不会失败!
  3. SUB有多个PUB要连接 - 所以我会有多个这样的连接。
  4. 我担心我可能会在SUB方面遇到过多的套接字,不好的部分 - 其中一半我可能永远不会使用!

    我错过了一些太明显的东西吗?

    由于 姆欧

0 个答案:

没有答案