[英]Message Queueing Scenario - Queueing and remote web service
(Please see Slide Links below) I am trying to create and audit-able request and response service that interacts with a remote web service. (请参阅下面的幻灯片链接)我正在尝试创建与远程Web服务交互的,可审核的请求和响应服务。 I am having some trouble deciding on the correct implementation for my approach.
我在为我的方法选择正确的实现时遇到一些麻烦。 Basically, how I need the implementation to work is as follows.
基本上,我需要执行该工作的方式如下。
A Requester application (A) will generate a request XML and add it to a request 'queue'. 请求者应用程序(A)将生成请求XML,并将其添加到请求“队列”中。 A request processor will then get an unprocessed record from the 'queue' and POST it to a remote web service (X) with a unique ID, if the request is not successful the request is kept/(requestComplete flag = 0) in the request 'queue' to be retried at a later time.
然后,请求处理器将从“队列”中获取未处理的记录,并将其发布到具有唯一ID的远程Web服务(X),如果请求未成功,则请求将被保留/(requestComplete标志= 0) “队列”将在以后的时间重试。
If the request is successful it is kept/(requestComplete flag = 1) and is not retried 如果请求成功它被保持/(requestComplete标志= 1),并且不重试
At A later date a Receiver web service (B) receives a response from the 'X' service that was called in the request. 稍后,接收者Web服务(B)从请求中调用的“ X”服务接收响应。
'B' then searches through the request records to find the original request and correlates the 'A' request and the 'X' response (matching using the unique ID). 然后,“ B”搜索请求记录以查找原始请求,并将“ A”请求和“ X”响应相关联(使用唯一ID进行匹配)。
Some additional processing is done with the response and the record from the 'queue' is updated as completed. 响应会执行一些其他处理,并且来自“队列”的记录将更新为已完成。
In this way there is a complete audit trail from request to response. 这样,从请求到响应都有完整的审核跟踪。 I can see when the original request was made, if there is an error with the request by looking at the 'queue' record.
通过查看“队列”记录,可以看到原始请求是何时发出的,如果请求有错误。 Likewise with the response I can see when it was received if at all.
同样,通过响应,我可以看到何时收到响应。
There are two ways I have thought to implement this. 我曾考虑过两种实现此方法的方法。
Just a few notes: 只是一些注意事项:
If anyone has any suggestions or guidance on which avenue to pursue, any comments or any knowledge on best practices in dealing with scenarios above, it would be greatly beneficial. 如果有人对采用哪种方法有任何建议或指导,对上述方案的最佳做法有任何意见或知识,那将是非常有益的。
I would suggest looking at a service bus with sagas (my preference is Rhino Service Bus , but NServiceBus also has a lot of traction, and there's also Mass Transit ) 我建议您查看带有sagas的服务总线(我的首选是Rhino Service Bus ,但NServiceBus也有很多吸引力,并且还有Mass Transit )
Basically a service bus will handle the plumbing of enqueuing (aka sending) messages, and dequeueing (aka receiving & processing them). 基本上,服务总线将处理排队(又称为发送)和出队(又称为接收和处理)的消息。 A saga will then assist with maintaining state for a conversation (where a conversation consists of multiple messages).
然后,传奇将帮助维护对话的状态(对话包含多个消息)。
The issues of retrying later can be handled quite elegantly with delayed messages in Rhino Service Bus, and timeouts in NServiceBus (I have no experience of Mass Transit). Rhino Service Bus中的延迟消息和NServiceBus中的超时(我没有使用Mass Transit的经验)可以很好地处理稍后重试的问题。
I would store the result logs in a database to make it easier to query & report on. 我会将结果日志存储在数据库中,以使其更易于查询和报告。 I would also rather use a servicebus with MSMQ (or any other queue) than use a database table as a "queue" - the former is designed precisely for your scenario, whereas the latter is a much more generic product to handle many different scenarios and thus it won't be as efficient as a queue implementation (eg MSMQ) (although it can do it - but scaling becomes harder).
我还宁愿将服务总线与MSMQ(或任何其他队列)一起使用,而不是将数据库表用作“队列”-前者是专门为您的情况设计的,而后者是一种更通用的产品,可以处理许多不同的情况,并且因此,它不会像队列实现(例如MSMQ)那样高效(尽管它可以做到-但扩展变得更加困难)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.