开发者

Implementing a "saga timeout" using an IIS-hosted WCF service?

开发者 https://www.devze.com 2023-03-23 15:52 出处:网络
I have a fairly straightforward scatter-gather pattern implemented using an IIS-hosted web service (WCF) as both the request handler (broadcast) and aggregator.

I have a fairly straightforward scatter-gather pattern implemented using an IIS-hosted web service (WCF) as both the request handler (broadcast) and aggregator.

Everything runs pretty smoothly using the standard NetMsmqBinding, one-way message contracts, and WAS. But now we want to introduce a business rule, whereby the aggregator will only wait a certain amount of time (probably a few days) for the final responses; if some or all of them are not received, it should close out the batch and publish whatever information it has. Normally it would only initiate a publish when all endpoints have r开发者_StackOverflow社区eported.

I know that I can set message expirations on the broadcast messages so that the endpoints don't waste time doing unnecessary work, but what about triggering the early publish?

NServiceBus treats sagas as a first-class citizen, handling timeouts gracefully, and I know that BizTalk actually implements the entire scatter-gather as a single orchestration. But I don't want to have to deploy any new tools or services just for this one requirement.

Is there a way to implement a long-running batch timeout action using just WCF and MSMQ?

(Again - the aggregator is hosted in IIS, so I can't just set a timer; the app pool could be recycled or shut down at any time.)


You could implement your own, but you need to find a way to manage the timeouts for each instance of your requests, manage the state of each instance while it is waiting for the responses of each of the vendors, correlate the responses, and also introduce a pub/sub architecture to decouple the aggregator from the vendors in order so you can handle the events published by them.

In my opinion, this sounds like an awful lot of work and is exactly the type of thing that NServiceBus provides out of the box (and so much more). I would take another look at it. Businesses are always changing and saga's more common that we realise. It might be one requirement now, but that could change again soon.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号