Files
hangfire-ravendb/src/ConsoleSample/Program.cs
T

41 lines
1.4 KiB
C#
Raw Normal View History

2015-10-16 16:07:20 -05:00
using System;
using Hangfire;
using HangFire.Raven.Storage;
namespace ConsoleSample
{
public static class Program
{
public static int x = 0;
public static void Main()
{
// you can use Raven Storage and specify the connection string and database name
GlobalConfiguration.Configuration
.UseColouredConsoleLogProvider()
2016-02-19 13:35:27 +00:00
.UseRavenStorage("http://localhost:8080", "hangfire", "apikeytest");
2015-10-16 16:07:20 -05:00
// you can use Raven Embedded Storage which runs in memory!
//GlobalConfiguration.Configuration
// .UseColouredConsoleLogProvider()
// .UseEmbeddedRavenStorage();
//you have to create an instance of background job server at least once for background jobs to run
var client = new BackgroundJobServer();
2015-10-17 21:06:49 -05:00
//BackgroundJob.Enqueue(() => Console.WriteLine("Background Job: Hello, world!"));
BackgroundJob.Enqueue(() => test());
//RecurringJob.AddOrUpdate(() => test(), Cron.Minutely);
2015-10-16 16:07:20 -05:00
Console.WriteLine("Press Enter to exit...");
Console.ReadLine();
}
2015-10-18 01:39:08 -05:00
[AutomaticRetry(Attempts = 2, LogEvents = true, OnAttemptsExceeded = AttemptsExceededAction.Delete)]
2015-10-16 16:07:20 -05:00
public static void test()
{
Console.WriteLine($"{x++} Cron Job: Hello, world!");
2015-10-17 21:06:49 -05:00
throw new ArgumentException("fail");
2015-10-16 16:07:20 -05:00
}
}
}