public void Raise <T>(T @event) { var chain = new BehaviorChain(Builder, contextStacker); chain.Add <LoadHandlersBehavior>(); chain.Add <InvokeHandlersBehavior>(); using (var context = new BehaviorContext(Builder, new TransportMessage(), contextStacker)) { var logicalMessages = new LogicalMessages { new LogicalMessage(typeof(T), @event) }; context.Set(logicalMessages); chain.Invoke(context); } }
void HandleTransportMessage(IBuilder childBuilder, TransportMessage msg) { // construct behavior chain - look at configuration and possibly the incoming transport message var chain = new BehaviorChain(childBuilder, contextStacker); chain.Add <MessageHandlingLoggingBehavior>(); if (ConfigureImpersonation.Impersonate) { chain.Add <ImpersonateSenderBehavior>(); } chain.Add <AuditBehavior>(); chain.Add <ForwardBehavior>(); chain.Add <UnitOfWorkBehavior>(); chain.Add <ApplyIncomingTransportMessageMutatorsBehavior>(); chain.Add <RaiseMessageReceivedBehavior>(); if (!disableMessageHandling) { chain.Add <ExtractLogicalMessagesBehavior>(); chain.Add <ApplyIncomingMessageMutatorsBehavior>(); chain.Add <CallbackInvocationBehavior>(); chain.Add <LoadHandlersBehavior>(); chain.Add <SagaPersistenceBehavior>(); chain.Add <InvokeHandlersBehavior>(); } chain.Invoke(msg); }