简体   繁体   English

Azure服务结构:IReliableQueue

[英]Azure service fabric : IReliableQueue

I'm using azure service fabric for our new service. 我正在使用天蓝色服务面料进行新服务。

For the client-facing gateway I have a stateless service getting request using a Web API endpoint, the actual work is done using reliable stateless actors. 对于面向客户端的网关,我有一个使用Web API端点的无状态服务获取请求,实际工作是使用可靠的无状态actor完成的。

As suggested by Sean McKenna - MSFT in this question , I put the incoming request in a ReliableQueue and storing the result in a ReliableDictionary. 正如Sean McKenna - MSFT在这个问题中所建议的,我将传入的请求放在ReliableQueue中并将结果存储在ReliableDictionary中。

I don't understand how to implement this, where do I define the ReliableQueue?? 我不明白如何实现这个,我在哪里定义ReliableQueue? it is obvious(?) that enqueue a job will occur at the Web API controller, but where do i dequeue an object and when? 很明显(?)将一个作业排入Web API控制器,但是我在哪里出列一个对象以及什么时候出现? there are no event firing telling me an object was added?? 没有事件触发告诉我添加了一个对象?

As you see I'll love some help on this 如你所见,我会在这方面得到一些帮助

Thanks 谢谢

In the question you refer to, I am describing the pattern shown in the WordCount sample . 在您提到的问题中,我正在描述WordCount示例中显示的模式。

In that case, the application is made up of a stateless gateway service and a stateful processing service. 在这种情况下,应用程序由无状态网关服务和有状态处理服务组成。 The client input is sent to the stateless gateway, then relayed on to the stateful service, where it is initially persisted in a ReliableQueue . 客户端输入被发送到无状态网关,然后中继到有状态服务,在那里它最初保存在ReliableQueue In parallel, there's an infinite while loop running inside the RunAsync method pulling items off of the queue and processing them, with the results being stored in a ReliableDictionary . 同时,在RunAsync方法中运行一个无限的while循环,将项目从队列中拉出并处理它们,结果存储在ReliableDictionary This pattern is useful when you want to quickly ACK back to the client that you received (and safely persisted!) its input and can afford to perform the real processing asynchronously. 当您希望快速确认回到您收到(并安全地保持!)其输入的客户端并且能够以异步方式执行实际处理时,此模式非常有用。

Note that if you intend to store your state in a ReliableQueue / ReliableDictionary , there probably isn't much value in doing the processing using a stateless actor. 请注意,如果您打算将状态存储在ReliableQueue / ReliableDictionary ,那么使用无状态actor进行处理可能没什么价值。 You'd be better off to just move that logic into a type within the stateful service and do the processing there as you will likely save yourself a network hop back and forth. 您最好将该逻辑移动到有状态服务中的类型中并在那里进行处理,因为您可能会来回保存自己的网络跳跃。

If I understand your question correctly, you are just searching for a way to communicate from a Stateless Service to an Actor. 如果我正确理解您的问题,您只是在寻找从无状态服务到演员的通信方式。 If so, you don't need a reliable queue - just make a call with an ActorProxy instance: 如果是这样,您不需要可靠的队列 - 只需使用ActorProxy实例进行调用:

ActorId actorId = new ActorId("YourActorId");
string applicationName = "fabric:/YourAppName";
IYourActor actor = ActorProxy.Create<IYourActor>(actorId, applicationName);
await dtoActor.DoWork(new WorkItem());

Service Fabric will route this call for you. Service Fabric将为您路由此呼叫。

You can have a Stateful Service that will dequeue items from the queue in the RunAsync method (see here for a RunAsync() example). 您可以拥有一个有状态服务,该服务将使RunAsync方法中的队列中的项目出列(有关RunAsync()示例,请参见此处 )。

When you dequeue an item you can communicate with an actor using ActorProxy and ask it to do the work. 当您将某个项目出列时,您可以使用ActorProxy与actor进行通信,并要求它执行该项工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Azure中收集Service Fabric群集日志 - Collect Service Fabric Cluster logs in Azure 带有微服务的Azure Service Fabric多租户 - Azure Service Fabric Multi-Tenancy with microservice Azure Service Fabric中的ASP.NET Core应用程序中的WebpackDevMiddleware - WebpackDevMiddleware in ASP.NET Core app in Azure Service Fabric Azure服务结构-长时间后返回结果 - Azure service fabric - return result after long time Azure Service Fabric是否与Docker做同样的事情? - Does Azure Service Fabric do the same thing as Docker? VB中的Windows Azure存储:不在托管服务或开发结构中运行 - Windows Azure Storage in VB: Not running in a hosted service or the Development Fabric Azure Service Fabric错误:访问被拒绝。 部署失败 - Azure Service Fabric error: Access is denied. Failed to deploy Azure应用服务上的Service Fabric客户端。 无法加载DLL&#39;FabricCommon.dll&#39; - Service Fabric Client on Azure App Service. Unable to load DLL 'FabricCommon.dll' Azure Service Fabric:直接在ASP.NET Core有状态服务中使用可靠的集合 - Azure Service Fabric: Using Reliable collections in ASP.NET Core Stateful Service directly 在Azure Service Fabric解决方案中通过Docker容器发布ASP.NET MVC项目 - Publish ASP.NET MVC Project via Docker Container in Azure Service Fabric solution
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM