protected override void Setup(FeatureConfigurationContext context)
        {
            var settings   = context.Settings.Get <ExactlyOnceEntitiesSettings>("ExactlyOnce.Settings");
            var httpClient = settings.HttpClient ?? new HttpClient();

            context.Pipeline.Register(b =>
            {
                var dispatcher        = b.Build <IDispatchMessages>();
                var handlerCollection = new ISideEffectsHandler[]
                {
                    new MessagingWithClaimCheckSideEffectsHandler(settings.MessageStore, dispatcher),
                    new MachineInterfaceInvocationSideEffectsHandler(httpClient),
                };
                var processor = new ExactlyOnceProcessor <IExtendable>(handlerCollection, new NServiceBusDebugLogger());
                return(new ExactlyOnceBehavior(processor, settings.MessageStore, settings.GetCorrelatedApplicationStateStore()));
            },
                                      "Ensures side effects of processing messages by entities are persisted exactly once.");

            context.Pipeline.Register(new CaptureOutgoingMessagesBehavior(settings.MessageStore), "Captures the outgoing messages.");

            context.Pipeline.Register(new LoadMessageBodyBehavior(settings.MessageStore), "Loads message bodies from store.");

            context.Pipeline.Register(new HttpClientBehavior(httpClient), "Adds HttpClient to the context.");
            context.Pipeline.Register(new MachineInterfaceFollowUpMessageHandlingBehavior(httpClient), "Issues the POST and DELETE requests in the machine interface");
        }
        public HumanInterfaceConnector(IApplicationStateStore <TPartition> applicationStateStore,
                                       IEnumerable <ISideEffectsHandler> sideEffectsHandlers,
                                       IMessageSession rootMessageSession,
                                       IDispatchMessages dispatcher,
                                       ITransactionInProgressStore transactionInProgressStore,
                                       IMessageStore messageStore)
        {
            this.applicationStateStore      = applicationStateStore;
            this.rootMessageSession         = rootMessageSession;
            this.transactionInProgressStore = transactionInProgressStore;
            this.messageStore = messageStore;

            var allHandlers = sideEffectsHandlers.Concat(new ISideEffectsHandler[]
            {
                new WebMessagingWithClaimCheckSideEffectsHandler(messageStore, dispatcher),
                new TransactionInProgressSideEffectHandler(transactionInProgressStore),
            });

            processor = new ExactlyOnceProcessor <object>(allHandlers.ToArray(), new NServiceBusDebugLogger());
        }
        public MachineInterfaceConnector(IApplicationStateStore <T> applicationStateStore,
                                         IEnumerable <ISideEffectsHandler> sideEffectsHandlers,
                                         IMessageSession rootMessageSession,
                                         IDispatchMessages dispatcher,
                                         IMessageStore messageStore,
                                         IMachineWebInterfaceRequestStore requestStore,
                                         IMachineWebInterfaceResponseStore responseStore)
        {
            this.applicationStateStore = applicationStateStore;
            this.rootMessageSession    = rootMessageSession;
            this.messageStore          = messageStore;
            this.requestStore          = requestStore;
            this.responseStore         = responseStore;

            var allHandlers = sideEffectsHandlers.Concat(new ISideEffectsHandler[]
            {
                new WebMessagingWithClaimCheckSideEffectsHandler(messageStore, dispatcher),
                new HttpResponseSideEffectsHandler(requestStore, responseStore),
            });

            processor = new ExactlyOnceProcessor <object>(allHandlers.ToArray(), new NServiceBusDebugLogger());
        }
Ejemplo n.º 4
0
 public ExactlyOnceBehavior(ExactlyOnceProcessor <IExtendable> exactlyOnceProcessor, IMessageStore messageStore, ICorrelatedApplicationStateStore applicationStateStore)
 {
     this.exactlyOnceProcessor  = exactlyOnceProcessor;
     this.messageStore          = messageStore;
     this.applicationStateStore = applicationStateStore;
 }