如何实施主动& JeroMQ中的备用队列作业处理系统? [英] How to implement an active & standby queue job-processing system in JeroMQ?

查看:163
本文介绍了如何实施主动& JeroMQ中的备用队列作业处理系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ZeroMQ .Context .Socket 实例,我可以推/拉消息

例如我的代码下面的队列设置如下:

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();






我的问题



Q1:如何在队列中实施主动/待机模式?

我的意思是将为一个主机和端口创建2个队列,如果一个队列(活动)发生故障,另一个(即备用)队列将立即启动以侦听/拉取消息。

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:是否有任何内置类要做这类任务?

推荐答案

你可以实现某种二进制启动模式。你的队列需要一个发现服务(在另一对套接字上)来了解彼此的状态。如果我没有弄错的话,没有标准功能来制作这样的队列。

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.

这篇关于如何实施主动& JeroMQ中的备用队列作业处理系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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