<small id='ruXAN'></small><noframes id='ruXAN'>

    • <bdo id='ruXAN'></bdo><ul id='ruXAN'></ul>

    1. <i id='ruXAN'><tr id='ruXAN'><dt id='ruXAN'><q id='ruXAN'><span id='ruXAN'><b id='ruXAN'><form id='ruXAN'><ins id='ruXAN'></ins><ul id='ruXAN'></ul><sub id='ruXAN'></sub></form><legend id='ruXAN'></legend><bdo id='ruXAN'><pre id='ruXAN'><center id='ruXAN'></center></pre></bdo></b><th id='ruXAN'></th></span></q></dt></tr></i><div id='ruXAN'><tfoot id='ruXAN'></tfoot><dl id='ruXAN'><fieldset id='ruXAN'></fieldset></dl></div>
      <tfoot id='ruXAN'></tfoot>

      <legend id='ruXAN'><style id='ruXAN'><dir id='ruXAN'><q id='ruXAN'></q></dir></style></legend>
    2. 具有 MassTransit、RabbitMQ 和 SignalR 的分布式架构

      时间:2023-08-24

        <small id='OUr3n'></small><noframes id='OUr3n'>

        <tfoot id='OUr3n'></tfoot>

            <i id='OUr3n'><tr id='OUr3n'><dt id='OUr3n'><q id='OUr3n'><span id='OUr3n'><b id='OUr3n'><form id='OUr3n'><ins id='OUr3n'></ins><ul id='OUr3n'></ul><sub id='OUr3n'></sub></form><legend id='OUr3n'></legend><bdo id='OUr3n'><pre id='OUr3n'><center id='OUr3n'></center></pre></bdo></b><th id='OUr3n'></th></span></q></dt></tr></i><div id='OUr3n'><tfoot id='OUr3n'></tfoot><dl id='OUr3n'><fieldset id='OUr3n'></fieldset></dl></div>
              <tbody id='OUr3n'></tbody>

            1. <legend id='OUr3n'><style id='OUr3n'><dir id='OUr3n'><q id='OUr3n'></q></dir></style></legend>
              • <bdo id='OUr3n'></bdo><ul id='OUr3n'></ul>

                本文介绍了具有 MassTransit、RabbitMQ 和 SignalR 的分布式架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我在

                2) 与第一个一样,但使用 Rest API 调用而不是来自 IIS 端的消费者

                3) 这篇文章的想法

                解决方案

                我使用 SignalR 的 hubs 执行此操作,并使用常规 MassTransit 消费者在服务器上观察事件.当观察到事件时,我触发事件处理程序,该处理程序使用集线器向连接的客户端分派.这样,事件会立即推送到浏览器,而不会在控制器中的服务器上留下未决的异步调用.

                您可以在 Fooidity 中看到这一点,它做了类似的事情:

                https://github.com/phatboyg/Fooidity/blob/develop/src/Fooidity.Management.Web/Hubs/ApplicationHubEventHandler.cs#L18

                使用GlobalHost解析Hub,然后在Hub上提升方法.可以使用组来区分事件上下文,这是按节点处理的 SignalR 功能.因此,只要每个节点都在观察事件,客户端就可以连接到任何集线器并得到通知.这非常适合负载平衡,而不必为 SignalR 使用繁重的集群背板——因为 RabbitMQ 对于事件分发来说是超级轻量级​​的.

                您也可以使用非持久队列来执行此操作,这使其速度更快——因为服务器重置/连接断开比代理崩溃更可能发生.

                身份验证在 ApplicationHub 内部处理,如相邻的源文件所示:https://github.com/phatboyg/Fooidity/blob/develop/src/Fooidity.Management.Web/Hubs/ApplicationHub.cs

                看看吧,希望对你有帮助.

                I'm developing distributed application with help of MassTransit and rabbitmq

                I have to provide ability to generate report on a web page without page reloading by click on a button, also I should call a windows service for data preparation (The service handles each request for 30sek - 1min).

                My first try based on this sample: 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);
                    }
                

                But as I understand it' not a better approach, because I'm keeping connection during all data preparation.

                I've read many articles and I have found three ways. Which way is preferred?

                1) Like on this article http://www.maldworth.com/2015/07/19/signalrchat-with-masstransit-v3/

                2) As first but with Rest API calling instead of Consumers from IIS side

                3) Idea from this article http://weblog.west-wind.com/posts/2013/Sep/04/SelfHosting-SignalR-in-a-Windows-Service

                解决方案

                I do this using hubs from SignalR, and observe events at the server using regular MassTransit consumers. When events are observed, I trigger the event handler, which dispatches using the Hub to connected clients. That way, the events are pushed down to the browser instantly without leaving an async call pending at the server in a controller.

                You can see this in Fooidity which does something similar:

                https://github.com/phatboyg/Fooidity/blob/develop/src/Fooidity.Management.Web/Hubs/ApplicationHubEventHandler.cs#L18

                Using the GlobalHost to resolve the Hub, then raising the method on the hub. The event context can be discriminated by using groups, which are a SignalR feature that is handled per node. So as long as every node is observing the event, clients can be connected to any hub and get notified. This works nicely for load balancing, without having to use a heavy cluster backplane for SignalR -- since RabbitMQ is super lightweight for event distribution.

                You can do it with non-durable queues as well, which makes it even faster -- since a server reset/connection drop is more likely than a broker crash.

                Authentication is handled inside the ApplicationHub, as shown in the adjacent source file: https://github.com/phatboyg/Fooidity/blob/develop/src/Fooidity.Management.Web/Hubs/ApplicationHub.cs

                Check it out, hopefully it helps.

                这篇关于具有 MassTransit、RabbitMQ 和 SignalR 的分布式架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:确保事件最终发布到消息队列系统的最佳方式 下一篇:如何检查 RabbitMQ 消息队列是否存在?

                相关文章

                最新文章

                  <tfoot id='RfQWm'></tfoot>
                1. <legend id='RfQWm'><style id='RfQWm'><dir id='RfQWm'><q id='RfQWm'></q></dir></style></legend>

                  <small id='RfQWm'></small><noframes id='RfQWm'>

                    <bdo id='RfQWm'></bdo><ul id='RfQWm'></ul>
                2. <i id='RfQWm'><tr id='RfQWm'><dt id='RfQWm'><q id='RfQWm'><span id='RfQWm'><b id='RfQWm'><form id='RfQWm'><ins id='RfQWm'></ins><ul id='RfQWm'></ul><sub id='RfQWm'></sub></form><legend id='RfQWm'></legend><bdo id='RfQWm'><pre id='RfQWm'><center id='RfQWm'></center></pre></bdo></b><th id='RfQWm'></th></span></q></dt></tr></i><div id='RfQWm'><tfoot id='RfQWm'></tfoot><dl id='RfQWm'><fieldset id='RfQWm'></fieldset></dl></div>