Exemplo n.º 1
0
        private static void Main()
        {
            // initialize Serilog

            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Warning()
                         .WriteTo.Console()
                         .CreateLogger();

            // initialize MassiveJobs

            JobsBuilder.Configure()
            .WithSerilog()
            .WithSettings("examples.")
            .WithRabbitMqBroker()
            .Build();

            Console.WriteLine("Testing periodic jobs. Press Enter to quit!");

            PeriodicJob.PublishPeriodic("test_periodic", "0/2 * * ? * *");

            Console.ReadLine();

            JobsBuilder.DisposeJobs();
        }
Exemplo n.º 2
0
        public void TestInit()
        {
            _timers       = new List <TestTimer>();
            _timeProvider = new TestTimeProvider();

            using (var db = new TestDbContext())
            {
                //db.Database.EnsureDeleted();
                //db.Database.EnsureCreated();
                db.Database.ExecuteSqlRaw("delete from massive_jobs.message_queue");
                db.Database.ExecuteSqlRaw("delete from massive_jobs.single_consumer_lock");
            }

            JobsBuilder.Configure()
            .WithSettings("tests.", s =>
            {
                s.PublishBatchSize                = 300;
                s.ImmediateWorkersBatchSize       = 1000;
                s.MaxDegreeOfParallelismPerWorker = 2;
                s.ImmediateWorkersCount           = 2;
                s.ScheduledWorkersCount           = 2;
                s.PeriodicWorkersCount            = 2;
            })
            .RegisterInstance <ITimeProvider>(_timeProvider)
            .RegisterScoped <ITimer>(f =>
            {
                var timer = new TestTimer();
                _timers.Add(timer);
                return(timer);
            })
            .WithSqlServerBroker <TestDbContext>()
            .RegisterScoped <TestDbContext, TestDbContext>()
            .Build();
        }
Exemplo n.º 3
0
        public void TestInit()
        {
            _counter = new Counter();

            _messages = new InMemoryMessages();

            _timers       = new List <TestTimer>();
            _timeProvider = new TestTimeProvider();

            JobsBuilder.Configure()
            .RegisterInstance(_settings)
            .RegisterInstance(_counter)
            .RegisterInstance <ITimeProvider>(_timeProvider)
            .RegisterScoped <ITimer>(f =>
            {
                var timer = new TestTimer();
                _timers.Add(timer);
                return(timer);
            })
            .WithInMemoryBroker(_messages)
            .Build();
        }
Exemplo n.º 4
0
        public void TestInit()
        {
            _performCount = 0;

            JobsBuilder.Configure()
            .WithSettings("tests.", s =>
            {
                s.PublishBatchSize                = 300;
                s.ImmediateWorkersBatchSize       = 1000;
                s.MaxDegreeOfParallelismPerWorker = 2;
                s.ImmediateWorkersCount           = 2;
                s.ScheduledWorkersCount           = 2;
                s.PeriodicWorkersCount            = 2;
            })
            .RegisterInstance <IJobTypeProvider>(new TypeProvider())
            .RegisterInstance <IJobSerializer>(new SimpleBinarySerializer())
            .WithRabbitMqBroker(s =>
            {
                s.VirtualHost   = "massivejobs.tests";
                s.PrefetchCount = 1000;
            })
            .Build();
        }