Example #1
0
        private static void Main(string[] args)
        {
            GlobalConfiguration.Configuration
            .UseColouredConsoleLogProvider()
            .UseSimpleAssemblyNameTypeSerializer()
            .UseRecommendedSerializerSettings()
            .UseResultsInContinuations()
            .UseMAMQPostgreSQLStorage(
                @"Host=localhost;Database=hangfire_test;Username=postgres;Password=innroad;Pooling=true",
                new PostgreSqlStorageOptions
            {
                EnableTransactionScopeEnlistment = true,
                PrepareSchemaIfNecessary         = true
                                                   // UsePageLocksOnDequeue = true,
                                                   // DisableGlobalLocks = true,
            }, new[] { "app2_queue" });

            RecurringJob.AddOrUpdate("app2_job", () => App2_Tasks.Do_App2_Task(), Cron.Minutely, TimeZoneInfo.Local, "app2_queue");

            var options = new BackgroundJobServerOptions
            {
                Queues = new[] { "app2_queue" }
            };

            using var server = new BackgroundJobServer(options);
            Console.WriteLine("Press Enter to exit...");
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            GlobalConfiguration.Configuration
            .UseMAMQSqlServerStorage(@"Server=.\SQLEXPRESS;Database=hangfire_test;Trusted_Connection=True;", new SqlServerStorageOptions
            {
                UsePageLocksOnDequeue = true,
                DisableGlobalLocks    = true,
            }, new[] { "app2_queue" })
            .SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
            .UseSimpleAssemblyNameTypeSerializer()
            .UseRecommendedSerializerSettings();

            RecurringJob.AddOrUpdate("app2_job", () => App2_Tasks.Do_App2_Task(), Cron.Minutely, TimeZoneInfo.Local, "app2_queue");

            var optoins = new BackgroundJobServerOptions
            {
                Queues = new[] { "app2_queue" }
            };

            using (var server = new BackgroundJobServer(optoins))
            {
                Console.WriteLine("Press Enter to exit...");
                Console.ReadLine();
            }
        }