예제 #1
0
        public override void SetUp()
        {
            _tracker = new AttemptTracker();

            var options = new JasperOptions();

            options.Extensions.UseMessageTrackingTestingSupport();
            options.Endpoints.As <TransportCollection>().Add(new StubTransport());

            options.Services.AddSingleton(_tracker);

            options.Endpoints.Publish(x => x.Message <ErrorCausingMessage>()
                                      .To("local://1".ToUri()));


            _host = JasperHost.For(options);

            _transport = _host.GetStubTransport();

            _graph = _host.Get <HandlerGraph>();
            _chain = _graph.ChainFor <ErrorCausingMessage>();


            _bus = _host.Get <IMessageContext>();
        }
예제 #2
0
        public void Handle(ErrorCausingMessage message, Envelope envelope, AttemptTracker tracker)
        {
            tracker.LastAttempt = envelope.Attempts;

            if (!message.Errors.ContainsKey(envelope.Attempts))
            {
                message.WasProcessed = true;

                return;
            }

            var type = GetExceptionType(message.Errors[envelope.Attempts]);
            var ex   = Activator.CreateInstance(type).As <Exception>();

            throw ex;
        }
예제 #3
0
        public override void SetUp()
        {
            _tracker = new AttemptTracker();

            var registry = new JasperRegistry();

            registry.Transports.ListenForMessagesFrom("stub://1".ToUri());
            registry.Services.AddSingleton(_tracker);
            registry.Publish.Message <ErrorCausingMessage>()
            .To("stub://1".ToUri());

            _host = JasperHost.For(registry);

            _transport = _host.GetStubTransport();

            _graph = _host.Get <HandlerGraph>();
            _chain = _graph.ChainFor <ErrorCausingMessage>();


            _bus = _host.Get <IMessageContext>();
        }
예제 #4
0
        public override void SetUp()
        {
            _transport = new StubTransport();
            _tracker   = new AttemptTracker();

            var registry = new JasperBusRegistry();

            registry.ListenForMessagesFrom("stub://1".ToUri());
            registry.Services.AddService <ITransport>(_transport);
            registry.Services.AddService(_tracker);
            registry.SendMessage <ErrorCausingMessage>()
            .To("stub://1".ToUri());

            _runtime = JasperRuntime.For(registry);

            _graph = _runtime.Container.GetInstance <HandlerGraph>();
            _chain = _graph.ChainFor <ErrorCausingMessage>();


            _bus = _runtime.Container.GetInstance <IServiceBus>();
        }
예제 #5
0
        public override void SetUp()
        {
            _tracker = new AttemptTracker();

            var registry = new JasperRegistry();

            registry.Transports.ListenForMessagesFrom("stub://1".ToUri());
            registry.Services.AddSingleton <ITransport, StubTransport>();
            registry.Services.AddSingleton(_tracker);
            registry.Publish.Message <ErrorCausingMessage>()
            .To("stub://1".ToUri());

            _runtime = JasperRuntime.For(registry);

            _transport = _runtime.Container.GetAllInstances <ITransport>().OfType <StubTransport>().Single();

            _graph = _runtime.Get <HandlerGraph>();
            _chain = _graph.ChainFor <ErrorCausingMessage>();


            _bus = _runtime.Get <IMessageContext>();
        }