public Task HandleReceive(RabbitContext rabbitContext, RabbitMessageHandler next) { var service = rabbitContext.ContextServiceProvider.GetRequiredService(subscriptionType); var @event = rabbitContext.ReceivedMessage.ToEventMessage().MessageReader.Read <T>(); return(((IEventHandler <T>)service).Handle(@event)); }
private Task EventBusListener_OnMessageReceived(object sender, RabbitContext rabbitContext) { var subscription = this.subscriptionManager.GetSubscription(rabbitContext.EventName); if (subscription == null) { return(Task.CompletedTask); } return(subscription.Handler(rabbitContext, rabbitContext.ReceivedMessage.ToEventMessage())); }
public Task Handler(RabbitContext rabbitContext, EventMessage eventMessage) { return(Task.Run(async() => { using (rabbitContext) { await this.receiveExecutionPipe.Execute(rabbitContext, eventMessage); } })); }
private RabbitContext CreateContext(Event @event, IModel channel, MessageStream messageStream) { var context = new RabbitContext( @event.EventName, rabbitMessageSerializer, channel, messageStream, serviceProvider.CreateScope() ); return(context); }
public Task HandlePublish(RabbitContext rabbitContext, RabbitMessageHandler next) { return(next()); }