Exemplo n.º 1
0
        public void Register(Container container)
        {
            container.RegisterSingleton(typeof(AttemptDataProvider),
                                        new AttemptDataProvider(ConfigurationManager.ConnectionStrings["Cassandra"].ConnectionString,
                                                                "publishattempts", new Mappings[] { new SendAttemptsMappings() }));

            container.RegisterSingleton <BeforeSendInterceptor>();
            //container.RegisterSingleton<TestConsumer>();

            container.RegisterSingleton <ISendResultProcessor, DefaultSendResultProcessor>();
            container.RegisterSingleton <ISendAttemptRepository, CassandraAttemptRepository>();

            var builder = PlatformBusFactory.Create(container.GetInstance);

            builder.AddBeforeSendAction <BeforeSendInterceptor>();
            container.RegisterSingleton(typeof(IPlatformBus), () => builder.Bus);

            container.RegisterSingleton <ISendRetryStrategy, BackgroundSendRetryStrategy>();
            container.RegisterSingleton <IConsumeRetryStrategy, BackgroundConsumeRetryStrategy>();


            var registration = Lifestyle.Singleton.CreateRegistration <HangfireSendRetryScheduler>(container);

            container.AddRegistration(typeof(IConsumeRetryScheduler), registration);
            container.AddRegistration(typeof(ISendRetryScheduler), registration);
        }
Exemplo n.º 2
0
        public void TestOne()
        {
            //    var res = this.dataProvider.Session.Execute("SELECT * FROM notsentattempt");
            //    Console.WriteLine(JsonConvert.SerializeObject(res, Formatting.Indented));

            //    res = this.dataProvider.Session.Execute("SELECT * FROM sendattempt");
            //    Console.WriteLine(JsonConvert.SerializeObject(res, Formatting.Indented));

            //this.platformBus.SendAndCreate("EventLocalSend", "4EF69428-FD92-4E0B-B28D-5102C80AD90D",
            //   "3E6D82D2-3C22-4041-96F3-169CCD5823A2", new ExtendSessionMessage());

            //var global = this.dataProvider.Mapper.Fetch<SendAttemptEntity>();

            //Console.WriteLine(JsonConvert.SerializeObject(global, Formatting.Indented));

            PlatformBusFactory.DynamicAddInfrustructure(this.platformBus as PlatformBus, new[]
            {
                new ExchangeItem()
                {
                    Name = "3E6D82D2-3C22-4041-96F3-169CCD5823A2",
                    Type = "topic",
                    In   = new[]
                    {
                        new InMessage()
                        {
                            Key   = "4EF69428-FD92-4E0B-B28D-5102C80AD90D",
                            Type  = "Platform.Utils.Communication.Contracts.Auth.ExtendSessionMessage, Platform.Utils.Communication.Contracts",
                            Name  = "EventLocalSendConsumer",
                            React = "Platform.Utils.Tests.TestConsumer, Platform.Utils.Tests"
                        }
                    },
                    Out           = new OutMessage[0],
                    PrefetchCount = 1
                }
            });

            Console.Read();
        }