static void Main(string[] args) { NameValueCollection properties = new NameValueCollection(); // 远程输出配置 properties["quartz.scheduler.exporter.type"] = "Quartz.Simpl.RemotingSchedulerExporter, Quartz"; properties["quartz.scheduler.exporter.port"] = "556"; properties["quartz.scheduler.exporter.bindName"] = "QuartzScheduler"; properties["quartz.scheduler.exporter.channelType"] = "tcp"; properties["quartz.scheduler.instanceName"] = "XmlConfiguredInstance"; // set thread pool info properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz"; properties["quartz.threadPool.threadCount"] = "6"; properties["quartz.threadPool.threadPriority"] = "Normal"; // job initialization plugin handles our xml reading, without it defaults are used properties["quartz.plugin.xml.type"] = "Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz"; properties["quartz.plugin.xml.fileNames"] = "E:\\MicrosoftTFS\\慢查询任务机制\\Test\\quartz_jobs.xml"; //配置文件修改后,需要重启Quartz服务 ISchedulerFactory sf = new StdSchedulerFactory(properties); IScheduler sched = sf.GetScheduler(); sched.Start(); RedisQueueManager.DoQueue <string>((msg) => { Console.WriteLine(msg); }, "test"); }
public void SetUp() { // Arrange conn = new RedisConnection(); queue = new RedisQueueManager(conn); }
/// <summary> /// 测试Redis队列 /// </summary> static void TestRedisQueueManager() { // string input = ""; //while (true) //{ // input = Console.ReadLine(); // RedisQueueManager.Push("lxsh", input); //} RedisQueueManager.DoQueue <string>(str => { Console.WriteLine(str); }, "lxsh"); }
public IHttpActionResult OpenBag(RBCreateBag bag) { var rt = ISoftSmart.Core.IoC.IoCFactory.Instance.CurrentContainer.Resolve <IRedBag>();//使用接口 //bag.CreateTime = DateTime.Now; //var res = await Task.Run(() =>rt.GetBag(bag)); var Code = string.Empty; var ResponseMessage = string.Empty; RBCreateBag Result = null; //Task.Run(() => //{ bag.CreateTime = DateTime.Now; var db = RedisManager.Instance.GetDatabase(); if (StackExchangeRedisExtensions.HasKey(db, CacheKey.BagKey)) { lock (_locker) { var bagcache = StackExchangeRedisExtensions.Get <RBCreateBag>(db, CacheKey.BagKey); if (bagcache.BagNum > 0) { decimal curAmount = 0; var openResult = GenerateBag(bagcache, out curAmount); Code = "SUCCESS"; ResponseMessage = "抢到" + curAmount + "元!"; Result = openResult; RedisQueueManager.Push <RBCreateBag>(CacheKey.OpenBagKey, bagcache); StackExchangeRedisExtensions.Set(db, CacheKey.BagKey, bagcache); } else { Code = "ERROR"; ResponseMessage = "红包抢完了!"; bag.BagStatus = 1; //RedisQueueManager.DoQueue<int>((s) => //{ // rt.ChangeBagStatus(bag); //}, CacheKey.OpenBagKey); rt.ChangeBagStatus(bag); StackExchangeRedisExtensions.Remove(db, CacheKey.BagKey); } } } else { StackExchangeRedisExtensions.Set(db, CacheKey.BagKey, bag); } return(Ok(new APIResponse <RBCreateBag> { Code = Code, ResponseMessage = ResponseMessage, Result = Result })); //}); //return Ok(new APIResponse<RBCreateBag> //{ // Code = Code, // ResponseMessage = ResponseMessage, // Result = Result //}); }