当前位置: 首页>>代码示例>>C#>>正文


C# IInMemoryReceiveEndpointConfigurator.Handler方法代码示例

本文整理汇总了C#中IInMemoryReceiveEndpointConfigurator.Handler方法的典型用法代码示例。如果您正苦于以下问题:C# IInMemoryReceiveEndpointConfigurator.Handler方法的具体用法?C# IInMemoryReceiveEndpointConfigurator.Handler怎么用?C# IInMemoryReceiveEndpointConfigurator.Handler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IInMemoryReceiveEndpointConfigurator的用法示例。


在下文中一共展示了IInMemoryReceiveEndpointConfigurator.Handler方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConfigureInputQueueEndpoint

 protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator)
 {
     configurator.Handler<PingMessage>(async context =>
     {
         await context.RespondAsync(new PongMessage(context.Message.CorrelationId));
     });
 }
开发者ID:kotvisbj,项目名称:MassTransit,代码行数:7,代码来源:InMemorySpeed_Specs.cs

示例2: ConfigureInputQueueEndpoint

        protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator 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)));
        }
开发者ID:kotvisbj,项目名称:MassTransit,代码行数:26,代码来源:DelayRetry_Specs.cs

示例3: ConfigureInputQueueEndpoint

        protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator)
        {
            configurator.Handler<JToken>(async context =>
            {
                await Console.Out.WriteLineAsync($"Received the token! {context.Message}");

                _completed.TrySetResult(context.Message);
            });
        }
开发者ID:kotvisbj,项目名称:MassTransit,代码行数:9,代码来源:ConsumeJToken_Specs.cs

示例4: ConfigureInputQueueEndpoint

 protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator)
 {
     long value = 0;
     configurator.Handler<PingMessage>(async context =>
     {
         if (Interlocked.Increment(ref value) == 1000)
             _completed.TrySetResult(true);
     });
 }
开发者ID:MassTransit,项目名称:MassTransit,代码行数:9,代码来源:PerformanceCounter_Specs.cs

示例5: ConfigureInputQueueEndpoint

        protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator 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));
            });
        }
开发者ID:MassTransit,项目名称:MassTransit,代码行数:10,代码来源:RegisterUser_Specs.cs

示例6: ConfigureInputQueueEndpoint

        protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator)
        {
            base.ConfigureInputQueueEndpoint(configurator);

            #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously

            configurator.Handler<A>(async m =>
            {
                throw new System.Exception("Booom!");
            });

            configurator.Handler<Fault<A>>(async m =>
            {
                _faultTaskTcs.TrySetResult(m.Message);
            });

            #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously

        }
开发者ID:MassTransit,项目名称:MassTransit,代码行数:19,代码来源:BinarySerializer_Specs.cs

示例7: ConfigureInputQueueEndpoint

        protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator)
        {
            _count = 0;
            configurator.Handler<Interval>(async context =>
            {
                Interlocked.Increment(ref _count);
            });

            _done = Handled<Done>(configurator);
        }
开发者ID:kotvisbj,项目名称:MassTransit,代码行数:10,代码来源:Recurring_Specs.cs

示例8: ConfigureInputQueueEndpoint

        protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator)
        {
            configurator.UseInMemoryOutbox();

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

            configurator.Handler<PingMessage>(context =>
            {
                _pingReceived.TrySetResult(context);

                context.Respond(new PongMessage(context.Message.CorrelationId));

                throw new IntentionalTestException("This time bad things happen");
            });
        }
开发者ID:MattKotsenas,项目名称:MassTransit,代码行数:15,代码来源:Outbox_Specs.cs

示例9: ConfigureInputQueueEndpoint

        protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator 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);
        }
开发者ID:MassTransit,项目名称:MassTransit,代码行数:19,代码来源:Introspection_Specs.cs

示例10: ConfigureInputQueueEndpoint

        protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator)
        {
            base.ConfigureInputQueueEndpoint(configurator);

            _received = Handled<IA>(configurator);

            _tweaked = GetTask<IA>();

            configurator.Handler<IA>(async context => _tweaked.TrySetResult(context.Message), x =>
            {
                x.UseTransform(t =>
                {
                    t.Set(p => p.Second, context => "World");
                });
            });
        }
开发者ID:kotvisbj,项目名称:MassTransit,代码行数:16,代码来源:SetProperty_Specs.cs


注:本文中的IInMemoryReceiveEndpointConfigurator.Handler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。