public async Task ExecuteAsync(ReceivePipelineContext ctx, Func <Task> next) { var message = ctx.Load <Message>(); var messageId = await _dataStorage.StoreReceivedMessageAsync(new Persistence.ReceivedDbMessage() { Body = message.Body, Headers = message.Headers }); if (messageId == null) { //TODO: Canceled vote in context? return; } //TODO: co tutaj robi transakcja? bo powinno się kończyć na samym dole if (Transaction.Current != null) { var commitAction = ctx.Load <Func <Task> >(ReceivePipelineContext.CommitMessageAction); // Transaction.Current.TransactionCompleted += (sender, args) => // { // Transaction.Current.en // if(args.Transaction.TransactionInformation.) // commitAction() // } } await FuncInvoker.Invoke(next); //coś jeszcze będzie potrzebne? Mógł nie mieć handlera }
public async Task ExecuteAsync(ReceivePipelineContext ctx, Func <Task> next) { var message = ctx.Load <Message>(); var messageType = message.Headers[MessageHeaders.EventType]; var handlerType = MessageHandlersMapper.GetHandler(messageType); //TODO: może ten scope powinien się na równi z transakcją dziać, nawet by pasowało using (var scope = _serviceProvider.CreateScope()) { var handler = (IMessageHandler)scope.ServiceProvider.GetRequiredService(handlerType); await handler.HandleAsync((IMessage)ctx.Load <Message>().Body); } await FuncInvoker.Invoke(next); }
public async Task ExecuteAsync(ReceivePipelineContext ctx, Func <Task> next) { var transportMessage = ctx.Load <TransportMessage>(); var serializer = _serializerFactory.Create(transportMessage); ctx.Save <Message>(await serializer.DeserializeAsync(transportMessage)); await FuncInvoker.Invoke(next); }