Beispiel #1
0
 internal static void Start(IChannelProvider channelProvider, IComponentChannelIdentifierRepository componentChannelIdentifierRepository, IHubContext <IngestEventsHub> hubContext)
 {
     channelProvider.GetMessageSource <SerializedEvent>(componentChannelIdentifierRepository.GetChannelIdentifierFor(IngestEventConstants.ChannelIdentifierCode)).GetChannel().Subscribe(evt =>
     {
         hubContext.Clients.All.SendAsync("onNewEvent", evt.GetEventObject());
     });
 }
 public static IDisposable RegisterCommandHandler <Command, CommandHandler>(this IChannelProvider channelProvider, ChannelIdentifier channelIdentifier, ILifetimeScope iocLifetimeScope)
     where CommandHandler : ICommandHandler <Command>
 {
     // Resolve the commmand handler once to verify that it is correctly registered in the iocContainer.
     // This is done to force the method to fail early (when making the registration) instead of late (when receiving a message of the given command type).
     iocLifetimeScope.Resolve <CommandHandler>();
     return(channelProvider.GetMessageSource <Command>(channelIdentifier).GetChannel().Subscribe(command =>
     {
         var correlationId = Guid.NewGuid();
         WriteToConsole <Command, CommandHandler>(correlationId, "Starting message processing");
         WriteToConsole <Command, CommandHandler>(correlationId, JsonConvert.SerializeObject(command, Formatting.None));
         iocLifetimeScope.Resolve <CommandHandler>().Handle(command);
         WriteToConsole <Command, CommandHandler>(correlationId, "message processing completed");
     }));
 }