Exemplo n.º 1
0
        protected override void EstablishContext()
        {
            base.EstablishContext();

            InMemorySagaRepository <RegisterUserSaga> sagaRepository = SetupSagaRepository <RegisterUserSaga>();

            // this just shows that you can easily respond to the message
            RemoteBus.SubscribeHandler <SendUserVerificationEmail>(
                x =>
            {
                RemoteBus.ShouldHaveSubscriptionFor <UserVerificationEmailSent>();
                RemoteBus.Publish(new UserVerificationEmailSent(x.CorrelationId, x.Email));
            });

            RemoteBus.SubscribeSaga(sagaRepository);

            LocalBus.ShouldHaveSubscriptionFor <RegisterUser>();
            LocalBus.ShouldHaveSubscriptionFor <UserVerificationEmailSent>();
            LocalBus.ShouldHaveSubscriptionFor <UserValidated>();
        }
        protected override void EstablishContext()
        {
            base.EstablishContext();

            var sagaRepository = new InMemorySagaRepository <ClaimRequestSaga>();

            //these subscriptions are to replace the Timeout Service
            RemoteBus.SubscribeHandler <ScheduleTimeout>(
                x =>
            {
                RemoteBus.ShouldHaveSubscriptionFor <TimeoutScheduled>();
                RemoteBus.Publish(new TimeoutScheduled {
                    CorrelationId = x.CorrelationId, TimeoutAt = x.TimeoutAt
                });
            });

            RemoteBus.SubscribeHandler <CancelTimeout>(
                x =>
            {
                RemoteBus.ShouldHaveSubscriptionFor <TimeoutCancelled>();
                RemoteBus.Publish(new TimeoutCancelled {
                    CorrelationId = x.CorrelationId
                });
            }
                );

            //RemoteBus.SubscribeHandler<ClaimRequestCreatedPendingVerificationEvent>(x =>
            //    {
            //        Debug.WriteLine("Claim Created Pending Verification event received.");
            //    });

            RemoteBus.SubscribeSaga(sagaRepository);

            //event messages that the Saga is subscribed to
            LocalBus.ShouldHaveSubscriptionFor <ClaimRequestCreatedPendingVerificationEvent>();
            LocalBus.ShouldHaveSubscriptionFor <CardUseVerifiedEvent>();
            LocalBus.ShouldHaveSubscriptionFor <TimeoutExpired>();
        }