Esempio n. 1
0
 protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
 {
     configurator.Handler<PingMessage>(async context =>
     {
         await context.RespondAsync(new PongMessage(context.Message.CorrelationId));
     });
 }
Esempio n. 2
0
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            _count = 0;

            _received = GetTask<ConsumeContext<PingMessage>>();

            configurator.Handler<PingMessage>(async context =>
            {
                if (_timer == null)
                    _timer = Stopwatch.StartNew();

                if (_count++ < 2)
                {
                    Console.WriteLine("{0} now is not a good time", DateTime.UtcNow);
                    throw new IntentionalTestException("I'm so not ready for this jelly.");
                }

                _timer.Stop();

                Console.WriteLine("{0} okay, now is good (retried {1} times)", DateTime.UtcNow, context.Headers.Get("MT-Redelivery-Count", default(int?)));

                // okay, ready.
                _receivedTimeSpan = _timer.Elapsed;
                _received.TrySetResult(context);
            }, x => x.UseScheduledRedelivery(Retry.Intervals(1000,2000)));
        }
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            _consumer = new OneMessageConsumer(GetTask<MessageA>());


            configurator.Consumer(() => _consumer);
        }
 protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
 {
     Handler<PingMessage>(configurator, async context =>
     {
         throw new SerializationException("This is fine, forcing death");
     });
 }
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            _consumer = new OneMessageConsumer(GetTask<MessageA>());

            object instance = _consumer;

            configurator.Instance(instance);
        }
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            // TODO would be nice to support serialization per receiving endpoint

            // configurator.UseJsonSerializer();

            _requestReceived = Handler<A>(configurator, context => context.RespondAsync(new B()));
        }
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            _clearingApi = Substitute.For<IClearingApi>();
            _machine = new ClearingSaga(_clearingApi);
            _repository = new InMemorySagaRepository<ClearingSagaState>();

            configurator.StateMachineSaga(_machine, _repository);
        }
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            _accountingLogicFacade = Substitute.For<IAccountingLogicFacade>();
            var requestSettings = Substitute.For<RequestSettings>();
            _machine = new GatewaySaga(new DepositResponseFactory(), new ClearingRequestFactory(), _accountingLogicFacade, requestSettings);
            _repository = new InMemorySagaRepository<GatewaySagaState>();

            configurator.StateMachineSaga(_machine, _repository);
        }
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            _first = Handler<FirstMessage>(configurator, async context =>
            {
                await context.ScheduleMessage(DateTime.Now, new SecondMessage());
            });

            _second = Handled<SecondMessage>(configurator);
        }
Esempio n. 10
0
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            var sagaRepository = new InMemorySagaRepository<RegisterUserSaga>();
            configurator.Saga(sagaRepository);

            configurator.Handler<SendUserVerificationEmail>(async x =>
            {
                await Bus.Publish(new UserVerificationEmailSent(x.Message.CorrelationId, x.Message.Email));
            });
        }
Esempio n. 11
0
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            _count = 0;
            configurator.Handler<Interval>(async context =>
            {
                Interlocked.Increment(ref _count);
            });

            _done = Handled<Done>(configurator);
        }
Esempio n. 12
0
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            configurator.UseRetry(Retry.None);

            Handler<PingMessage>(configurator, async context =>
            {
                _attempts++;
                throw new IntentionalTestException();
            });
        }
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            long value = 0;
            configurator.Handler<PingMessage>(async context =>
            {
                if (Interlocked.Increment(ref value) == 1000)
                    _completed.TrySetResult(true);

            });
        }
Esempio n. 14
0
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            base.ConfigureInputQueueEndpoint(configurator);

            configurator.UseTransform<A>(t =>
            {
                t.Set(x => x.Second, context => "World");
            });

            _received = Handled<A>(configurator);
        }
Esempio n. 15
0
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            _commandHandler = Handler<SecureCommand>(configurator, async context =>
            {
                ConsumeContext<UserCredentials> credentials;
                if (context.TryGetMessage(out credentials))
                    _credentials.SetResult(credentials.Message);
            });

            _credentialsHandler = Handled<UserCredentials>(configurator);
        }
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            _header = GetTask<ClaimsIdentity>();

            _handled = Handler<PingMessage>(configurator, context =>
            {
                _header.TrySetResult(context.Headers.Get<ClaimsIdentity>("Claims-Identity"));

                return TaskUtil.Completed;
            });
        }
Esempio n. 17
0
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            base.ConfigureInputQueueEndpoint(configurator);

            configurator.UseTransform<A>(t =>
            {
                // Replace modifies the original message, versus Set which leaves the original message unmodified
                t.Replace(x => x.Second, context => "World");
            });

            _received = Handled<A>(configurator);
        }
Esempio n. 18
0
        public void Configure(IReceiveEndpointConfigurator configurator)
        {
            var partitioner = configurator.CreatePartitioner(ConsumerLimit);

            configurator.Consumer(_scheduleMessageConsumerFactory, x =>
                x.Message<ScheduleMessage>(m => m.UsePartitioner(partitioner, p => p.Message.CorrelationId)));

            configurator.Consumer(_cancelScheduledMessageConsumerFactory, x =>
                x.Message<CancelScheduledMessage>(m => m.UsePartitioner(partitioner, p => p.Message.TokenId)));

            _configureMessageScheduler.SchedulerAddress = configurator.InputAddress;
        }
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            base.ConfigureInputQueueEndpoint(configurator);

            _repository = new InMemorySagaRepository<Request_Specs.TestState>();

            var settings = new RequestSettingsImpl(ServiceQueueAddress, QuartzQueueAddress, TimeSpan.FromSeconds(1));

            _machine = new TestStateMachine(settings);

            configurator.StateMachineSaga(_machine, _repository);
        }
Esempio n. 20
0
            protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
            {
                string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;

                string messageDataPath = Path.Combine(baseDirectory, "MessageData");

                var dataDirectory = new DirectoryInfo(messageDataPath);

                _repository = new FileSystemMessageDataRepository(dataDirectory);

                configurator.UseMessageData<MessageWithBigData>(_repository);

                _received = Handled<MessageWithBigData>(configurator);

                configurator.UseMessageData<MessageWithByteArray>(_repository);

                _receivedBytes = Handled<MessageWithByteArray>(configurator);
            }
Esempio n. 21
0
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            configurator.Handler<PingMessage>(async context =>
            {
            }, x =>
            {
                x.UseRateLimit(100, TimeSpan.FromSeconds(1));
                x.UseConcurrencyLimit(32);
            });

            _handled = Handled<PingMessage>(configurator);

            var consumer = new MultiTestConsumer(TestTimeout);

            consumer.Consume<PingMessage>();
            consumer.Consume<PongMessage>();

            consumer.Configure(configurator);
        }
 public static void Configure(Type sagaType, IReceiveEndpointConfigurator configurator, ILifetimeScope scope, string name)
 {
     GetOrAdd(sagaType).Configure(configurator, scope, name);
 }
Esempio n. 23
0
 protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
 {
     _ping = Handler<PingMessage>(configurator, async x =>
     {
         throw new InvalidOperationException("This is an expected test failure");
     });
 }
Esempio n. 24
0
 /// <summary>
 /// Registers a handler on the receive endpoint that is cancelled when the test is canceled
 /// and completed when the message is received.
 /// </summary>
 /// <typeparam name="T">The message type</typeparam>
 /// <param name="configurator">The endpoint configurator</param>
 /// <param name="expectedCount">The expected number of messages</param>
 /// <returns></returns>
 protected Task <ConsumeContext <T> > Handled <T>(IReceiveEndpointConfigurator configurator, int expectedCount)
     where T : class
 {
     return(BusTestHarness.Handled <T>(configurator, expectedCount));
 }
Esempio n. 25
0
 protected override void ConfigureSaga(IReceiveEndpointConfigurator endpointConfigurator, ISagaConfigurator <JobState> sagaConfigurator)
 {
     sagaConfigurator.UseMessageRetry(r => r.Immediate(5));
     //sagaConfigurator.UseInMemoryOutbox();
 }
 void IExecuteActivityDefinition <TActivity, TArguments> .Configure(IReceiveEndpointConfigurator endpointConfigurator,
                                                                    IExecuteActivityConfigurator <TActivity, TArguments> consumerConfigurator)
 {
 }
Esempio n. 27
0
 protected override void ConfigureConsumer(IReceiveEndpointConfigurator endpointConfigurator,
                                           IConsumerConfigurator <TestBatchConsumer> consumerConfigurator)
 {
     endpointConfigurator.UseInMemoryOutbox();
     consumerConfigurator.Options <BatchOptions>(o => o.SetMessageLimit(5).SetTimeLimit(2000));
 }
 public void Configure(string name, IReceiveEndpointConfigurator configurator)
 {
     _callback(name, configurator);
 }
Esempio n. 29
0
 protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
 {
     configurator.StateMachineSaga(_machine, _repository);
 }
Esempio n. 30
0
 public ManagementEndpointConfigurator(IReceiveEndpointConfigurator configurator)
 {
     _configurator = configurator;
 }
 /// <summary>
 /// Applies the saga state machine to the endpoint.
 /// </summary>
 /// <param name="busName"></param>
 /// <param name="endpointName"></param>
 /// <param name="configurator"></param>
 public void Apply(string busName, string endpointName, IReceiveEndpointConfigurator configurator)
 {
     SagaStateMachineConfiguratorCache.Configure(definition.Type, configurator, context);
 }
        /// <summary>
        /// Configure all registered consumers on the receive endpoint
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="provider"></param>
        public static void ConfigureConsumers(this IReceiveEndpointConfigurator configurator, IServiceProvider provider)
        {
            var registration = provider.GetRequiredService <IRegistration>();

            registration.ConfigureConsumers(configurator);
        }
        /// <summary>
        /// Configure the execute activity on the receive endpoint
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="provider"></param>
        /// <param name="activityType"></param>
        public static void ConfigureExecuteActivity(this IReceiveEndpointConfigurator configurator, IServiceProvider provider, Type activityType)
        {
            var registration = provider.GetRequiredService <IRegistration>();

            registration.ConfigureExecuteActivity(activityType, configurator);
        }
 /// <summary>
 /// Serialize messages using the BSON message serializer
 /// </summary>
 /// <param name="configurator"></param>
 public static void UseBsonSerializer(this IReceiveEndpointConfigurator configurator)
 {
     configurator.SetMessageSerializer(() => new BsonMessageSerializer());
 }
Esempio n. 35
0
 /// <summary>
 /// Configures the endpoint, with consumers, handlers, sagas, etc.
 /// </summary>
 public void Configure(IReceiveEndpointConfigurator configurator)
 {
     // message consumers, middleware, etc. are configured here
 }
 public void Configure(IReceiveEndpointConfigurator configurator, IServiceProvider services)
 {
     configurator.Consumer(new MicrosoftExtensionsDependencyInjectionConsumerFactory <T>(services));
 }
Esempio n. 37
0
 protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
 {
     configurator.Saga(_repository);
 }
Esempio n. 38
0
 protected override void ConfigureConsumer(IReceiveEndpointConfigurator endpointConfigurator,
                                           IConsumerConfigurator <PingConsumer> consumerConfigurator)
 {
 }
Esempio n. 39
0
            protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
            {
                _messageDataRepository = new InMemoryMessageDataRepository();

                configurator.UseMessageData<MessageWithByteArray>(_messageDataRepository);

                _received = Handled<MessageWithByteArray>(configurator);
            }
        /// <summary>
        /// Serialize messages using the BSON message serializer with AES Encryption
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="keyProvider">
        /// The custom key provider to provide the symmetric key for encryption of plaintext message and decryption of ciphertext message
        /// </param>
        public static void UseEncryption(this IReceiveEndpointConfigurator configurator, ISecureKeyProvider keyProvider)
        {
            var streamProvider = new AesCryptoStreamProviderV2(keyProvider);

            configurator.UseEncryptedSerializerV2(streamProvider);
        }
Esempio n. 41
0
        /// <summary>
        /// Configure the execute activity on the receive endpoint
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="context"></param>
        /// <param name="activityType"></param>
        public static void ConfigureExecuteActivity(this IReceiveEndpointConfigurator configurator, IComponentContext context, Type activityType)
        {
            var registration = context.Resolve <IRegistration>();

            registration.ConfigureExecuteActivity(activityType, configurator);
        }
Esempio n. 42
0
 protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
 {
     // we have to do this explicitly, since the metadata is not exposed by Ninject
     configurator.Saga <SimpleSaga>(_container);
 }
Esempio n. 43
0
        public void Configure(IReceiveEndpointConfigurator executeEndpointConfigurator, IReceiveEndpointConfigurator compensateEndpointConfigurator,
                              IConfigurationServiceProvider scopeProvider)
        {
            ConfigureCompensate(compensateEndpointConfigurator, scopeProvider);

            ConfigureExecute(executeEndpointConfigurator, scopeProvider, compensateEndpointConfigurator.InputAddress);
        }
Esempio n. 44
0
 protected override void ConfigureSaga(IReceiveEndpointConfigurator endpointConfigurator, ISagaConfigurator <SagaNameSaga> sagaConfigurator)
 {
     endpointConfigurator.UseMessageRetry(r => r.Intervals(500, 1000));
 }
Esempio n. 45
0
 /// <summary>
 /// Registers a handler on the receive endpoint that is completed after the specified handler is
 /// executed and canceled if the test is canceled.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="configurator"></param>
 /// <param name="handler"></param>
 /// <returns></returns>
 protected Task <ConsumeContext <T> > Handler <T>(IReceiveEndpointConfigurator configurator, MessageHandler <T> handler)
     where T : class
 {
     return(BusTestHarness.Handler(configurator, handler));
 }
Esempio n. 46
0
 protected override void ConfigureConsumer(IReceiveEndpointConfigurator endpointConfigurator,
                                           IConsumerConfigurator <ConvertVideoJobConsumer> consumerConfigurator)
 {
     consumerConfigurator.Options <JobOptions <ConvertVideo> >(options =>
                                                               options.SetRetry(r => r.Interval(3, TimeSpan.FromSeconds(30))).SetJobTimeout(TimeSpan.FromMinutes(10)).SetConcurrentJobLimit(10));
 }
Esempio n. 47
0
 /// <summary>
 /// Registers a handler on the receive endpoint that is cancelled when the test is canceled
 /// and completed when the message is received.
 /// </summary>
 /// <typeparam name="T">The message type</typeparam>
 /// <param name="configurator">The endpoint configurator</param>
 /// <param name="filter">Filter the messages based on the handled consume context</param>
 /// <returns></returns>
 protected Task <ConsumeContext <T> > Handled <T>(IReceiveEndpointConfigurator configurator, Func <ConsumeContext <T>, bool> filter)
     where T : class
 {
     return(BusTestHarness.Handled(configurator, filter));
 }
Esempio n. 48
0
 private void RegisterConsumerType(IReceiveEndpointConfigurator receiveEndpointConfigurator, Type consumerType)
 {
     _logger.Debug($"Register {consumerType.FullName} using {_consumerFactory.GetType().FullName}");
     receiveEndpointConfigurator.Consumer(consumerType, _consumerFactory.Create);
 }
 protected virtual void ConfigureServiceQueueEndpoint(IReceiveEndpointConfigurator configurator)
 {
 }
Esempio n. 50
0
 protected virtual void ConfigureReceiveEndpoint(IReceiveEndpointConfigurator configurator)
 {
     configurator.Saga(TestRepository);
 }
Esempio n. 51
0
 protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
 {
     configurator.UseRetry(Retry.Immediate(3));
     Handler<PingMessage>(configurator, async context =>
     {
         Interlocked.Increment(ref _attempts);
         throw new IntentionalTestException();
     });
 }
Esempio n. 52
0
 public static void Configure(Type sagaType, IReceiveEndpointConfigurator configurator, ISagaStateMachineFactory sagaStateMachineFactory,
                              ISagaRepositoryFactory repositoryFactory, IStateMachineActivityFactory activityFactory)
 {
     GetOrAdd(sagaType).Configure(configurator, sagaStateMachineFactory, repositoryFactory, activityFactory);
 }
Esempio n. 53
0
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            _accepted = Handled<DispatchAccepted>(configurator);

            base.ConfigureInputQueueEndpoint(configurator);
        }
Esempio n. 54
0
        /// <summary>
        /// Configure all registered consumers on the receive endpoint
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="context"></param>
        public static void ConfigureConsumers(this IReceiveEndpointConfigurator configurator, IComponentContext context)
        {
            var registration = context.Resolve <IRegistration>();

            registration.ConfigureConsumers(configurator);
        }
Esempio n. 55
0
 protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
 {
     configurator.UseRetry(Retry.Immediate(2));
     configurator.Saga(_repository);
 }
Esempio n. 56
0
 protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
 {
     _handler = Handled <IProxyMe>(configurator);
 }
 public static void Configure(Type sagaType, IReceiveEndpointConfigurator configurator, IUnityContainer container)
 {
     GetOrAdd(sagaType).Configure(configurator, container);
 }
 /// <summary>
 /// Registers a saga using the container that has the repository resolved from the container
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="configurator"></param>
 /// <param name="context"></param>
 /// <param name="configure"></param>
 /// <returns></returns>
 public static void Saga <T>(this IReceiveEndpointConfigurator configurator, IServiceContext context, Action <ISagaConfigurator <T> > configure = null)
     where T : class, ISaga
 {
     Saga(configurator, context.GetInstance <IContainer>(), configure);
 }
Esempio n. 59
0
 protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
 {
     configurator.LoadFrom(_container);
 }
Esempio n. 60
0
 protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
 {
     _handled = Handled <PingMessage>(configurator);
 }