微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jesque Java 版的 Resque

程序名称:jesque

授权协议: Apache

操作系统: 跨平台

开发语言: Java

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 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(); }

jesque 官网

https://github.com/gresrun/jesque

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐