Java 版的 Resque jesque
Git@OSC 的 Android 和 iOS 客户端全面开源
jesque 是 Resque 的Java语言实现版。
使用示例:
// Configurationfinal Config config = new ConfigBuilder().build();// Add a job to the queuefinal 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 queuefinal Job job = new Job("TestAction", new Object[]{ 1, 2.3, true, "test", Arrays.asList("inner", 4.5)});final long delay = 10; // in secondsfinal long future = System.currentTimeMillis() + (delay * 1000); // timestampfinal Client client = new ClientImpl(config);client.delayedEnqueue("fooDelay", job, future);client.end();// Start a worker to run jobs from the queuefinal 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 shutdowntry { Thread.sleep((delay * 1000) + 5000); } catch (Exception e){} // Give ourselves time to processworker.end(true);try { workerThread.join(); } catch (Exception e){ e.printStackTrace(); }