Created
March 14, 2025 18:21
-
-
Save hishaamn/cee9ebb782483d161eb343a4533a9168 to your computer and use it in GitHub Desktop.
Updated InitializeBuses class with single constructor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Globalization; | |
using System.Threading.Tasks; | |
using Sitecore.Diagnostics; | |
using Sitecore.Events; | |
using Sitecore.Messaging; | |
using Sitecore.Messaging.Events; | |
using Sitecore.Pipelines; | |
public class InitializeBuses | |
{ | |
private readonly IMessageBusStarter _busStarter; | |
public InitializeBuses(IMessageBusStarter busStarter) | |
{ | |
_busStarter = busStarter ?? throw new ArgumentNullException(nameof(busStarter)); | |
} | |
public void Process(PipelineArgs args) | |
{ | |
Dictionary<string, bool> busStartResults = new Dictionary<string, bool>(); | |
_busStarter.Start( | |
busName => | |
{ | |
busStartResults.Add(busName, true); | |
Log.Info($"Messaging: IMessageBus started successfully: '{busName}'", this); | |
Event.RaiseEvent("messaging:busstarted", new MessageBusInitializedEventArgs(busName, true)); | |
}, | |
(busName, ex) => | |
{ | |
busStartResults.Add(busName, false); | |
Log.Error($"Messaging: IMessageBus failed to start '{busName}'.", ex, this); | |
Event.RaiseEvent("messaging:busstarted", new MessageBusInitializedEventArgs(busName, false)); | |
} | |
).ContinueWith(t => | |
Event.RaiseEvent("messaging:allBusesInitialized", new AllMessageBusesInitializedEventArgs(busStartResults))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment