Package net.greghaines.jesque.worker

Examples of net.greghaines.jesque.worker.MapBasedJobFactory


        }
    }

    private static void doWork(final List<Job> jobs, final Map<String, ? extends Class<? extends Runnable>> jobTypes,
            final WorkerListener listener, final WorkerEvent... events) {
        final Worker worker = new WorkerImpl(CONFIG, Arrays.asList(TEST_QUEUE), new MapBasedJobFactory(jobTypes));
        if (listener != null && events.length > 0) {
            worker.getWorkerEventEmitter().addListener(listener, events);
        }
        final Thread workerThread = new Thread(worker);
        workerThread.start();
View Full Code Here


                jobs.add(new Job("FailAction"));
            }
            TestUtils.enqueueJobs("bar", jobs, config);
        }
        final Worker worker = new WorkerImpl(config, Arrays.asList("foo0", "bar", "baz"),
                new MapBasedJobFactory(map(entry("TestAction", TestAction.class),
                        entry("FailAction", FailAction.class))));
        final Thread workerThread = new Thread(worker);
        workerThread.start();

        TestUtils.enqueueJobs("inf", Arrays.asList(new Job("InfiniteAction")), config);
        final Worker worker2 = new WorkerImpl(config, Arrays.asList("inf"),
                new MapBasedJobFactory(map(entry("InfiniteAction", InfiniteAction.class))));
        final Thread workerThread2 = new Thread(worker2);
        workerThread2.start();
        worker2.togglePause(true);

        workerThread.join();
View Full Code Here

    @Test
    @Ignore
    public void issue6() throws InterruptedException {
        final Worker worker = new WorkerImpl(config, Arrays.asList("foo"),
                new MapBasedJobFactory(map(entry("TestAction", TestAction.class),
                        entry("FailAction", FailAction.class))));
        final Thread workerThread = new Thread(worker);
        workerThread.start();

        for (int i = 0; i < 10; i++) {
View Full Code Here

            jedis.quit();
        }

        // Create and start worker
        final Worker worker = new WorkerImpl(config, Arrays.asList(delayTestQueue),
                new MapBasedJobFactory(map(entry("TestAction", TestAction.class))));
        final Thread workerThread = new Thread(worker);
        workerThread.start();

        // start second thread
        final Worker worker2 = new WorkerImpl(config, Arrays.asList(testQueue),
                new MapBasedJobFactory(map(entry("TestAction", TestAction.class))));
        final Thread workerThread2 = new Thread(worker2);
        workerThread2.start();

        try { // Wait a bit to ensure the worker had time to process the job
            Thread.sleep(1000 * 6);
 
View Full Code Here

     * Create a new AdminImpl which subscribes to {@link ResqueConstants#ADMIN_CHANNEL}, registers the
     * {@link PauseCommand} and {@link ShutdownCommand} jobs, and creates a new Jedis connection.
     * @param config the Jesque configuration
     */
    public AdminImpl(final Config config) {
        this(config, set(ADMIN_CHANNEL), new MapBasedJobFactory(map(
                entry("PauseCommand", PauseCommand.class),
                entry("ShutdownCommand", ShutdownCommand.class))));
    }
View Full Code Here

TOP

Related Classes of net.greghaines.jesque.worker.MapBasedJobFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.