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))); }
protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { configurator.Handler<PingMessage>(async context => { await context.RespondAsync(new PongMessage(context.Message.CorrelationId)); }); }
protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { configurator.Handler <PingMessage>(async context => { await context.RespondAsync(new PongMessage(context.Message.CorrelationId)); }); }
protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { configurator.Handler <ProcessDocument>(async context => { if (!context.Message.StringData.HasValue) { throw new ArgumentException("StringData was not present."); } var stringData = await context.Message.StringData.Value; if (string.IsNullOrWhiteSpace(stringData)) { throw new ArgumentException("StringData was empty."); } _stringDataAddress = context.Message.StringData.Address; _byteDataAddress = context.Message.ByteData.Address; _streamDataAddress = context.Message.StreamData.Address; await context.RespondAsync <DocumentProcessed>(new { context.Message.CorrelationId, context.Message.StringData, StringByteData = context.Message.StringData, context.Message.ByteData, context.Message.StringValue, StringByteValue = context.Message.StringValue, context.Message.ByteValue, context.Message.StreamData }); }); }
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))); }
protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { configurator.Handler <PerformanceRequest>(async context => { await context.RespondAsync(new PerformanceResultImpl(context.Message.Id)); }); }
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); await context.Redeliver(TimeSpan.FromMilliseconds(1000)); return; } _timer.Stop(); Console.WriteLine("{0} okay, now is good (retried {1} times)", DateTime.UtcNow, context.Headers.Get(MessageHeaders.RedeliveryCount, default(int?))); // okay, ready. _receivedTimeSpan = _timer.Elapsed; _received.TrySetResult(context); }); }
protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { configurator.Handler <ComplexRequest>(async context => { await context.RespondAsync <ComplexResponse>(new { }); }); }
protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { configurator.Handler <SuperComplexRequest>(async context => { Console.WriteLine(Encoding.UTF8.GetString(context.ReceiveContext.GetBody())); await context.RespondAsync <SuperComplexResponse>(new { }); }); }
protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { configurator.Handler <JToken>(async context => { await Console.Out.WriteLineAsync($"Received the token! {context.Message}"); _completed.TrySetResult(context.Message); }); }
protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { long value = 0; configurator.Handler<PingMessage>(async context => { if (Interlocked.Increment(ref value) == 1000) _completed.TrySetResult(true); }); }
protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { base.ConfigureInMemoryReceiveEndpoint(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 }
protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { configurator.Handler<JToken>(async context => { await Console.Out.WriteLineAsync($"Received the token! {context.Message}"); _completed.TrySetResult(context.Message); }); }
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 }
protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { _count = 0; configurator.Handler<Interval>(async context => { Interlocked.Increment(ref _count); }); _done = Handled<Done>(configurator); }
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)); }); }
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.Replace(p => p.Second, _ => "World"))); }
protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { _count = 0; configurator.Handler <Interval>(async context => { Interlocked.Increment(ref _count); }); _done = Handled <Done>(configurator); }
protected override void ConfigureInMemoryReceiveEndpoint(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)); }); }
protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { _consumer = new FailingBatchConsumer(); configurator.UseMessageRetry(r => r.Immediate(1)); configurator.Consumer(() => _consumer); _task = GetTask <ConsumeContext <Fault <PingMessage> > >(); configurator.Handler <Fault <PingMessage> >(async m => _task.SetResult(m)); }
protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { long value = 0; configurator.Handler <PingMessage>(async context => { if (Interlocked.Increment(ref value) == 1000) { _completed.TrySetResult(true); } }); }
protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { _pingReceived = GetTask <ConsumeContext <PingMessage> >(); _scheduledMessage = GetTask <ScheduledMessage>(); configurator.Handler <PingMessage>(async context => { _pingReceived.TrySetResult(context); ScheduledMessage <PongMessage> scheduledMessage = await context.ScheduleSend(TimeSpan.FromSeconds(20), new PongMessage()); _scheduledMessage.TrySetResult(scheduledMessage); throw new IntentionalTestException("This time bad things happen"); }); _pongReceived = GetTask <ConsumeContext <PongMessage> >(); configurator.Handler <PongMessage>(async context => { _pongReceived.TrySetResult(context); }); }
protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { configurator.Handler <PingMessage>(async context => { try { await context.RespondAsync(new PongMessage(context.Message.CorrelationId), Pipe.Execute <SendContext>(x => x.Serializer = null)); } catch (Exception exception) { Console.WriteLine(exception); } }); }
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"); }); }
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"); }); }
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); }
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); }
protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { _completed = GetTask <ConsumeContext <DocumentProcessed> >(); configurator.Handler <DocumentProcessed>(async context => { if (!context.Message.StringData.HasValue) { throw new ArgumentException("StringData was not present."); } var stringData = await context.Message.StringData.Value; if (string.IsNullOrWhiteSpace(stringData)) { throw new ArgumentException("StringData was empty."); } _completed.TrySetResult(context); }); }
protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { _consumer = new FailingBatchConsumer(); configurator.UseScheduledRedelivery(r => r.Intervals(100)); configurator.UseMessageRetry(r => r.Immediate(1)); configurator.Consumer(() => _consumer); configurator.Handler <Fault <PingMessage> >(async m => { if (_firstId == m.Message.Message.CorrelationId) { _firstFault.SetResult(m); } if (_secondId == m.Message.Message.CorrelationId) { _secondFault.SetResult(m); } }); }
protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { _handled = GetTask <ConsumeContext <Documents> >(); configurator.Handler <Documents>(async context => { Assert.That(context.Message.Bodies, Is.Not.Null); Assert.That(context.Message.Bodies.Length, Is.EqualTo(2)); Assert.That(context.Message.Bodies[0].Body, Is.Not.Null); Assert.That(context.Message.Bodies[0].Body.HasValue); byte[] bodyValue = await context.Message.Bodies[0].Body.Value; Assert.That(bodyValue, Is.Not.Null); Assert.That(bodyValue.Length, Is.EqualTo(10000)); Assert.That(context.Message.Bodies[0].FileName, Is.Not.Null); Assert.That(context.Message.Bodies[0].FileName, Is.EqualTo("first.txt")); _handled.SetResult(context); }); }
protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { configurator.Handler <ProcessPayload>(async context => { if (!context.Message.Payload.HasValue) { throw new ArgumentException("Payload was not present."); } var payload = await context.Message.Payload.Value; if (payload == null) { throw new ArgumentException("Payload was null."); } _payloadAddress = context.Message.Payload.Address; await context.RespondAsync <PayloadProcessed>(new { context.Message.Payload, }); }); }
protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { _count = 0; _received = new[] { GetTask <ConsumeContext <PingMessage> >(), GetTask <ConsumeContext <PingMessage> >(), GetTask <ConsumeContext <PingMessage> >(), GetTask <ConsumeContext <PingMessage> >() }; _timestamps = new DateTime[4]; configurator.UseScheduledRedelivery(r => r.Intervals(1000, 2000, 3000)); configurator.Handler <PingMessage>(async context => { _received[_count].TrySetResult(context); _timestamps[_count] = DateTime.Now; _count++; throw new IntentionalTestException("I'm so not ready for this jelly."); }); }
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"); }); }); }
protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { configurator.Handler<PerformanceRequest>(async context => { await context.RespondAsync(new PerformanceResultImpl(context.Message.Id)); }); }
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); await context.Redeliver(TimeSpan.FromMilliseconds(1000)); return; } _timer.Stop(); Console.WriteLine("{0} okay, now is good (retried {1} times)", DateTime.UtcNow, context.Headers.Get(MessageHeaders.RedeliveryCount, default(int?))); // okay, ready. _receivedTimeSpan = _timer.Elapsed; _received.TrySetResult(context); }); }