4

I'm diving into Service Fabric (from the Cloud Services world) and am hitting a few speed bumps with how ReliableQueues work.

Let's say I have 2 stateful services StatefulService1 and StatefulService2.

If I need to have StatefulService1 send a message in a queue that StatefulService2 will pick up and read am I able to use ReliableQueues or are ReliableQueues isolated within the service they are created in?

If that is the case then what is the purpose of having ReliableQueues? The usual pattern behind them is for another process to act on the messages. I understand why isolating a Dictionary to a service would make sense, but not a queue...

Is my best option to rely on a traditional approach to send this message such as a Storage Queue or does ServiceFabric offer a solution for passing message queues between services?

UPDATE

Just want to clarify that I did attempt to dequeue a message created in StatefulService1 from within StatefulService2 and it came up empty. Dequeing from within StatefulService1 worked fine as expected.

4

4 回答 4

4

可靠集合位于内存数据结构中,不用于服务间通信。如果您想在StatefulService1StatefulService2之间建立通信通道,您有以下选择:

  1. 使用通信监听器。您可以为您选择的协议设置自定义侦听器,包括 HTTP、WCF 或您的自定义协议。您可以在本节中阅读有关它的更多信息。例如,StatefulService2可以打开StatefulService1可以 POST/GET 到的 HTTP 端点。

  2. 使用外部队列系统,如 Servicebus、EventHub 或 Kafka,StatefulService1可以向其中发布事件。StatefulService2可以是消费者服务,它使用队列中的事件并对其进行处理。

于 2017-09-21T08:01:53.500 回答
3

可靠集合(队列和字典)不用于通信。使用队列,它是一个 2PC,因此在任何时间点都只有一个进程可以访问它。请注意,当您使用带有分区的有状态服务时,要访问数据,两个服务实例必须位于同一分区上。不同的分区不能访问相同的数据。

依靠传统方法或实现自己的通信侦听器是可行的方法。使用传统方式 - 请记住,您需要决定是否要像服务一样对队列进行分区。

于 2017-03-05T21:04:20.750 回答
1

我不明白为什么服务不能托管可靠的集合/队列,而其他服务可以通过以下三种传输之一访问它:远程处理、WCF 和 HTTP。
显然,可靠的服务必须通过 API 公开集合/队列或实现 IService 接口

https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-connect-and-communicate-with-services

于 2017-11-10T22:37:03.860 回答
0

您必须在调用代码中添加故障处理重试模式,请参阅https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-services-communication,在这种情况下您在服务调用之间不需要队列来为您保存数据。

于 2017-09-20T08:22:45.470 回答