【发布时间】:2016-05-26 09:44:21
【问题描述】:
我在 MassTransit 和 rabbitmq 的帮助下开发分布式应用程序
我必须提供在网页上生成报告的能力,而无需通过单击按钮重新加载页面,我还应该调用 Windows 服务进行数据准备(该服务处理每个请求 30 秒 - 1 分钟)。
我基于此示例的第一次尝试:https://github.com/MassTransit/Sample-RequestResponse
[HttpPost]
public async Task<HttpStatusCodeResult> GenerateReport(string someJsonData)
{
var serviceAddress = new Uri(ConfigurationManager.AppSettings["BaseLineRecordService"]);
var client = this.Bus.CreateRequestClient<ICreateReportRequest, ICreateReportResponse>(serviceAddress, TimeSpan.FromHours(1));
ICreateReportResponse response = await client.Request(new CreateReportRequest());
reportHub.ShowRepordData(response); // Update data by SingleR
return new HttpStatusCodeResult(200);
}
但据我了解,这不是更好的方法,因为我在所有数据准备期间都保持连接。
我阅读了很多文章,并找到了三种方法。首选哪种方式?
1) 喜欢这篇文章http://www.maldworth.com/2015/07/19/signalrchat-with-masstransit-v3/
2) 与第一个一样,但使用 Rest API 调用而不是来自 IIS 端的消费者
3) 来自这篇文章的想法http://weblog.west-wind.com/posts/2013/Sep/04/SelfHosting-SignalR-in-a-Windows-Service
【问题讨论】:
标签: c# asp.net-mvc rabbitmq signalr masstransit