Esempio n. 1
0
        public async Task TestProcessorFailure()
        {
            var endpoint1 = new FailedEndpoint("id1", new OperationCanceledException());
            var endpoint2 = new FailedEndpoint("id1", new InvalidOperationException());

            var executor1 = new SyncEndpointExecutor(endpoint1, new NullCheckpointer());
            await Assert.ThrowsAsync <OperationCanceledException>(() => executor1.Invoke(Message1));

            var executor2 = new SyncEndpointExecutor(endpoint2, new NullCheckpointer());
            await Assert.ThrowsAsync <InvalidOperationException>(() => executor2.Invoke(Message1));
        }
Esempio n. 2
0
        public async Task TestCancellation()
        {
            var      retryStrategy = new FixedInterval(10, TimeSpan.FromSeconds(1));
            TimeSpan revivePeriod  = TimeSpan.FromHours(1);
            TimeSpan execTimeout   = TimeSpan.FromSeconds(60);
            var      config        = new EndpointExecutorConfig(execTimeout, retryStrategy, revivePeriod, true);

            var endpoint = new FailedEndpoint("id");

            IProcessor processor = endpoint.CreateProcessor();

            Assert.Equal(endpoint, processor.Endpoint);

            IEndpointExecutor executor = new SyncEndpointExecutor(endpoint, new NullCheckpointer(), config);
            Task running = executor.Invoke(Default);
            await executor.CloseAsync();

            await running;

            Assert.True(running.IsCompleted);
        }
Esempio n. 3
0
        public async Task SmokeTest()
        {
            var        cts       = new CancellationTokenSource();
            var        endpoint  = new FailedEndpoint("id1", "name1", "hub1", new InvalidOperationException());
            IProcessor processor = endpoint.CreateProcessor();

            Assert.True(processor.ErrorDetectionStrategy.IsTransient(new Exception()));

            Assert.Equal(endpoint, processor.Endpoint);
            ISinkResult <IMessage> result = await processor.ProcessAsync(new IMessage[0], cts.Token);

            Assert.True(result.SendFailureDetails.HasValue);
            result.SendFailureDetails.ForEach(ex => Assert.IsType <InvalidOperationException>(ex.RawException));
            Assert.True(processor.CloseAsync(CancellationToken.None).IsCompleted);

            var                    endpoint2  = new FailedEndpoint("id2");
            IProcessor             processor2 = endpoint2.CreateProcessor();
            ISinkResult <IMessage> result2    = await processor2.ProcessAsync(new IMessage[0], cts.Token);

            Assert.True(result2.SendFailureDetails.HasValue);
            result2.SendFailureDetails.ForEach(ex => Assert.IsType <Exception>(ex.RawException));
        }
Esempio n. 4
0
 public Processor(FailedEndpoint endpoint)
 {
     this.endpoint = endpoint;
 }