Esempio n. 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>();
        }
        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;
        }
        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>();
        }
Esempio n. 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>();
        }
Esempio n. 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>();
        }