本文整理汇总了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));
});
}
示例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)));
}
示例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);
});
}
示例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);
});
}
示例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));
});
}
示例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
}
示例7: ConfigureInputQueueEndpoint
protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator)
{
_count = 0;
configurator.Handler<Interval>(async context =>
{
Interlocked.Increment(ref _count);
});
_done = Handled<Done>(configurator);
}
示例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");
});
}
示例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);
}
示例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");
});
});
}