public IHttpActionResult Index() { var redisJobQueue = new RedisJobQueue(RedisJobQueue.Connection, "simple_queue"); redisJobQueue.AddJob("Thanh"); Thread.Sleep(2000); Debug.WriteLine("End Api"); return(Ok()); }
static void Main(string[] args) { var conn = ConnectionMultiplexer .Connect("localhost:6379,abortConnect=false"); var queue = new RedisJobQueue(conn, new JobQueueOptions { Namespace = "maddev", PollRate = TimeSpan.FromSeconds(1) }); queue.Queue.OnScheduledJob("test_interval", () => { System.Console.WriteLine(Guid.NewGuid() + " " + DateTime.UtcNow); return(Task.CompletedTask); }); queue.Queue.Start(); queue.Queue.Interval("test_interval", TimeSpan.FromSeconds(1)); System.Console.ReadLine(); }
public void ConfigRedisQueue() { var configurationOptions = new ConfigurationOptions { KeepAlive = 60, }; configurationOptions.EndPoints.Add("localhost", 6379); RedisJobQueue.Connection = new Lazy <IConnectionMultiplexer>(() => ConnectionMultiplexer.Connect(configurationOptions), true); var consumer = new RedisJobQueue(RedisJobQueue.Connection, "simple_queue"); consumer.OnJobReceived += new EventHandler <string>((obj, jobStr) => { for (int i = 0; i < 5; i++) { Debug.WriteLine(string.Format("Hello {0} the {1} time", jobStr, i + 1)); Thread.Sleep(1000); } }); consumer.AsConsumer(); }
public JobController(RedisJobQueue store) { _store = store; }