Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var x = new PollerBuilder();

            x.SetDescription("Rewardle's Points Commands Service")
            .SetDisplayName("PointsCommands")
            .SetServiceName("PointsCommands")
            .OverideServiceConfiguration(d => d.RunAsLocalService())
            .RegisterComponents(builder =>
            {
                builder.RegisterType <FakeServie>().As <IFakeService>();
            })
            .WithMultipleThreadsPerTask <ExampleTask>("HOla", "Description", 1, 3)
            //.WithTask<OtherTask>("dd", "Description", 4)
            .OnException((sender, ex) =>
            {
                Console.WriteLine("EXCEPTION: " + ex.Message);
                return(ex);
            })
            .OnLogDebug((sender, message) => Console.WriteLine("DEBUG: " + message))
            .OnLogInfo((sender, message) => Console.WriteLine("INFO: " + message))
            .OnLogWarning((sender, message) => Console.WriteLine("WARNING: " + message))
            .Build()
            .Start();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var x = new PollerBuilder();

            x.SetDescription("Rewardle's Points Commands Service")
                .SetDisplayName("PointsCommands")
                .SetServiceName("PointsCommands")
                .OverideServiceConfiguration(d => d.RunAsLocalService())
                .RegisterComponents(builder =>
                                    {
                                        builder.RegisterType<FakeServie>().As<IFakeService>();
                                    })
                .WithMultipleThreadsPerTask<ExampleTask>("HOla", "Description", 1, 3)
                //.WithTask<OtherTask>("dd", "Description", 4)
                .OnException((sender, ex) =>
                             {
                                 Console.WriteLine("EXCEPTION: " + ex.Message);
                                 return ex;
                             })
                .OnLogDebug((sender, message) => Console.WriteLine("DEBUG: " + message))
                .OnLogInfo((sender, message) => Console.WriteLine("INFO: " + message))
                .OnLogWarning((sender, message) => Console.WriteLine("WARNING: " + message))
                .Build()
                .Start();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            XmlConfigurator.Configure();
            var builder = new PollerBuilder();

            builder.SetDescription("Event Queue Worker for Rewardle.Boilerplate")
            .SetDisplayName("Rewardle.Boilerplate.Events")
            .SetServiceName("Rewardle.Boilerplate.Events")
            .OverideServiceConfiguration(configurator => configurator.RunAsLocalSystem())
            .OnException((sender, ex) =>
            {
                ILog logger = LogManager.GetLogger(sender.GetType());
                if (ex is TargetInvocationException)
                {
                    ex = ex.InnerException;
                }
                logger.Error(ex.Message, ex);
                return(ex);
            })
            .RegisterComponents(b => BootstrapperTasks.RunAllInAssemblies(b, typeof(WireUpEventStore).Assembly,
                                                                          typeof(WireUpDispatchers).Assembly, typeof(WireUpThreadFactory).Assembly))
            .WithTask <AsyncEventWorker <BoilerplateEventThreadExecutor> >(
                "BoilerplateEventWorker", "Process the events of the Boilerplate services", 2)
            .Build()
            .Start();
        }
Exemplo n.º 4
0
        public static PollerBuilder WithMultipleThreadsPerTask <TTask>(this PollerBuilder pollerBuilder, string taskName,
                                                                       string taskDescription,
                                                                       int intervalInSeconds, int numberOfThreads)
            where TTask : class, ITask
        {
            for (var i = 0; i < numberOfThreads; i++)
            {
                pollerBuilder.WithTask <TTask>(string.Format("{0}-{1}", taskName, i), taskDescription, intervalInSeconds);
            }

            return(pollerBuilder);
        }