How to implement an active & standby queue job-processing system in JeroMQ?

六月ゝ 毕业季﹏ 提交于 2019-12-22 04:08:23

问题


Using ZeroMQ .Context and .Socket instances, I am able to push/pull messages
for example below my code for a Queue like setup:

 ZMQ.Context context = ZMQ.context(1);

 //  Socket to send messages on
 ZMQ.Socket sender = context.socket(ZMQ.PUSH);
 sender.bind("tcp://*:5557");

 // Send messages
 sender.send("0", 0);

 ZMQ.Socket receiver = context.socket(ZMQ.PULL);
 receiver.connect("tcp://localhost:5557");

 // receive messages
 String string = new String(receiver.recv(0)).trim();

My questions are:

Q1: How to implement an active / standby mode in queues?

I mean there will be 2 queues, created for one host and port, if one queue ( the active ) fails, another ( i.e. the standby ) queue, will be started immediately to listen/pull messages.

Any example or guidance to implement it, will be more helpful.

Q2: Is there any built-in Class to do this type of task?


回答1:


you may implement some kind of binary start pattern. your queues need a discovery service (on another pair of sockets) to know about each other's state. if i'm not mistaken, there is no standard feature to make such queues.



来源:https://stackoverflow.com/questions/40909865/how-to-implement-an-active-standby-queue-job-processing-system-in-jeromq

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!