当前位置: 软件>java软件
Java 版的 Resque jesque
本文导语: jesque 是 Resque 的Java语言实现版。使用示例:// Configuration final Config config = new ConfigBuilder().build(); // Add a job to the queue final Job job = new Job("TestAction", new Object[]{ 1, 2.3, true, "test", Arrays.asList("inner", 4.5)}); final ...
jesque 是 Resque 的Java语言实现版。
使用示例:
// Configuration final Config config = new ConfigBuilder().build(); // Add a job to the queue final Job job = new Job("TestAction", new Object[]{ 1, 2.3, true, "test", Arrays.asList("inner", 4.5)}); final Client client = new ClientImpl(config); client.enqueue("foo", job); client.end(); // Add a job to the delayed queue final Job job = new Job("TestAction", new Object[]{ 1, 2.3, true, "test", Arrays.asList("inner", 4.5)}); final long delay = 10; // in seconds final long future = System.currentTimeMillis() + (delay * 1000); // timestamp final Client client = new ClientImpl(config); client.delayedEnqueue("fooDelay", job, future); client.end(); // Start a worker to run jobs from the queue final Worker worker = new WorkerImpl(config, Arrays.asList("foo"), new MapBasedJobFactory(map(entry("TestAction", TestAction.class)))); final Thread workerThread = new Thread(worker); workerThread.start(); // Wait a few secs then shutdown try { Thread.sleep((delay * 1000) + 5000); } catch (Exception e){} // Give ourselves time to process worker.end(true); try { workerThread.join(); } catch (Exception e){ e.printStackTrace(); }
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。