[英]NetMQ (ZeroMQ) how to make “Brokerless Reliability (Freelance Pattern)” works
I facing some problems with the example I got from the ZeroMQ Guide, looks like the class ZSocket and ZContext doesn't exist.我从 ZeroMQ 指南中获得的示例遇到了一些问题,看起来 class ZSocket 和 ZContext 不存在。 I'm totally new with ZeroMQ (just start lo learn) and I'm following the " ØMQ - The Guide ".
我是 ZeroMQ 的新手(刚开始学习),我正在遵循“ ØMQ - The Guide ”。 The first example about REQ-REP, which is very simple, worked well.
第一个关于 REQ-REP 的例子非常简单,运行良好。 But now I'm trying something more similar to my objective, the " Brokerless Reliability (Freelance Pattern) " and this one didn't work.
但是现在我正在尝试一些更类似于我的目标的东西,即“ 无代理可靠性(自由模式) ”,但这个没有奏效。
I'm using Visual Studio 2019 with C# code, I created a new project, added NetMQ V4.0.1.6 via Nuget and copied the server code to my project.我正在使用带有 C# 代码的 Visual Studio 2019,我创建了一个新项目,通过 Nuget 添加了 NetMQ V4.0.1.6,并将服务器代码复制到我的项目中。 I got errors with ZContext and ZSocket.
ZContext 和 ZSocket 出现错误。 I already check the API V3 and API V4 , they are clear different.
我已经检查了API V3和API V4 ,它们明显不同。 The guide is totally based on version 3 and I'm using V 4. I didn't find any document about the changes or updates or equivalent function/classes/methods and I don't know how to convert the example to the NetMQ V4.
该指南完全基于版本 3,我使用的是 V 4。我没有找到任何关于更改或更新或等效函数/类/方法的文档,我不知道如何将示例转换为 NetMQ V4 .
This is my test code:这是我的测试代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using NetMQ;
namespace Examples
{
static partial class Program
{
public static void FLServer1(string[] args)
{
//
// Freelance server - Model 1
// Trivial echo service
//
// Author: metadings
//
if (args == null || args.Length < 1)
{
Console.WriteLine();
Console.WriteLine("Usage: ./{0} FLServer1 [Endpoint]", AppDomain.CurrentDomain.FriendlyName);
Console.WriteLine();
Console.WriteLine(" Endpoint Where FLServer1 should bind on.");
Console.WriteLine(" Default is tcp://127.0.0.1:7780");
Console.WriteLine();
args = new string[] { "tcp://127.0.0.1:7780" };
}
using (var context = new ZContext())
using (var server = new ZSocket(context, ZSocketType.REP))
{
server.Bind(args[0]);
Console.WriteLine("I: echo service is ready at {0}", args[0]);
ZMessage message;
ZError error;
while (true)
{
if (null != (message = server.ReceiveMessage(out error)))
{
using (message)
{
server.Send(message);
}
}
else
{
if (error == ZError.ETERM)
return; // Interrupted
throw new ZException(error);
}
}
}
}
}
}
After long hours trying to understand that logic, I found a list of differences from ZeroMQ V3 and V4: https://github.com/zeromq/netmq/wiki/Migrating-to-v4经过长时间试图理解该逻辑后,我发现了与 ZeroMQ V3 和 V4 的差异列表: https://github.com/zeromq/netmq/wiki/Migrating-to-v4
Also, accidentally I found the example I was looking for: https://github.com/NetMQ/Samples/tree/master/src/Brokerless%20Reliability%20(Freelance%20Pattern)/Model%20One另外,我偶然发现了我正在寻找的示例: https://github.com/NetMQ/Samples/tree/master/src/Brokerless%20Reliability%20(Freelance%20Pattern)/Model%20One
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.