我正在寻找 ICommunicationListener
的 ZeroMQ 实现我可以将其与服务结构一起使用以在 Azure 上运行 ZeroMQ 端点。
我找了几个小时,但没有找到。有谁知道这个问题的解决方案?我目前使用“Service App Fabric/.net core 2.0 无状态服务”模板,
这允许我覆盖
IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
,
当我有ICommunicationListener
时ZeroMQ 的实现,
或覆盖 Task RunAsync(CancellationToken cancellationToken)
,
当我想自己设置套接字时。
我的第一次尝试不起作用:
protected override async Task RunAsync(CancellationToken cancellationToken)
{
using (var server = new ResponseSocket("tcp://xx.xx.xx.xx:xxxxx"))
{
while (!cancellationToken.IsCancellationRequested)
{
var message = server.ReceiveFrameBytes();
ServiceEventSource.Current.ServiceMessage(this.Context, "Message {0}",
System.Text.Encoding.UTF8.GetString(message));
}
}
}
上述结果是服务无法启动。除了这个之外找不到太多日志记录:
"There was an error during CodePackage activation.The service host terminated with exit code:255"
最佳答案
如果不存在,您可以通过创建 ICommunicationListener
的实现并从 CreateServiceInstanceListeners
返回该实现来创建自己的实现。
使用 OpenAsync
打开 channel 并开始监听。使用CloseAsync
停止监听。
看看this implementation for Service Bus ,寻求灵感。
关于azure - 需要在 Azure Service Fabric 上实现 ICommunicationListener 的 ZeroMQ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49990768/