![]() How can i get the right instance of the hub in my Consumer class? Or how can i access the IServiceCollection that. Public TestController(IHubContext hubContext) Private readonly IHubContext _hubContext I've tested accessing the hub in a controller, and the clients do show up: public class TestController : Controller So the problem is that _updaterHubContext.Clients in my Consumer class, always turn out to be empty. TaskUtil.Await(() => _busControl.StartAsync()) X.ReceiveEndpoint(host, "externalsystems.update",Į => ) Var host = x.Host(BusInitializer.GetUri("", rmqSettings), h => IRMQConnection rmqSettings = Config.GetRMQConnectionConfig("rmq-settings.json", "connection") Public static IServiceCollection _services Return Clients.Group(correlationId.ToString()).SendAsync("SEND_UPDATE", message) Īnd this is how the Bus and consumer is instantiated: public void ConfigureServices(IServiceCollection services) Public Task SendUpdate(Guid correlationId, string message) This is my SignalR hub: public class UpdatesHub : return _(()).SendAsync("SEND_UPDATE", ) // this.SendUpdate(, ) Public Task Consume(ConsumeContext context) ![]() Public UpdatesConsumer(IHubContext hubContext) Private readonly IHubContext _updaterHubContext So i've implemented this consumer in the API: public class UpdatesConsumer : Now i would like to use SignalR to send the status updates to the client. Thereafter, it updates the statemachine to keep track of the createoperation.įorm -> API -> StateMachine -> ExternalSystem -> StateMachine -> API The statemachine then sends a couple of create messages to my external system service which updates the database. When i post the 'create employee' form, a RabbitMQ message will be sent from the WebAPI to the statemachine. In this example i have 3 services running:ĮxternalSystem | StateMachine |. CRUD operations in my application result in updating the databases of the external systems. You can simulate scaleout by running the two profiles.My main problem is to get the right instance of the SignalR hub.Ĭontext: Im building a webapplication which communicates with a couple of external systems. The other addition we added is in the Properties/launchSettings.json, which lets us start 2 profiles on different ports. and the hub route is /chat versus /chatHub. NuGet\Install-Package MassTransit.SignalR -Version 8.0.7 This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package. The other difference is the Javascript client callback method name is "ReceiveMessage" versus "broadcastMessage", but both samples are nearly the same. The sample was based off of Microsoft's chat sample, which is nearly identical to the tutorial here, except the only different is it's stripped down to the bare minimum (no razor Pages, bootstrap or JQuery libraries). NuGet\Install-Package MassTransit.SignalR -Version 8.0.11 This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package. ![]() You can view the MassTransit Sample here. I'd recommend using their docker image to spin up the broker. We've included a sample ASP.NET Core project, and back end console application to show interoperability with the backplane. ToProtocolDictionary(.) helps facilitate this translation into the protocol for communication. SignalR supports multiple protocols for communicating with the Hub, the "serialized message" that is sent over the backplane is translated for each protocol method supported. Public void ConfigureServices ( IServiceCollection services ) Copy to clipboard Protocol Dictionary ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |