Package net.greghaines.jesque.worker

Examples of net.greghaines.jesque.worker.WorkerPool


        TestUtils.resetRedis(config);
    }

    @Test
    public void testAdminAndWorkerPool() {
        final WorkerPool workerPool = new WorkerPool(new Callable<WorkerImpl>() {
            public WorkerImpl call() {
                return new WorkerImpl(config, set(testQueue),
                        new MapBasedJobFactory(map(entry("TestAction", TestAction.class))));
            }
        }, 2);
        final Admin admin = new AdminImpl(config);
        admin.setWorker(workerPool);

        workerPool.run();
        final Thread adminThread = new Thread(admin);
        adminThread.start();

        Assert.assertFalse(workerPool.isPaused());

        try {
            // TODO: Do client stuff here
        } finally {
            TestUtils.stopWorker(admin, adminThread);
            try {
                workerPool.endAndJoin(false, 1000);
            } catch (Exception e) {
                log.warn("Exception while waiting for workerThread to join", e);
            }
        }
    }
View Full Code Here


    @Test
    public void testZREM() {
        // Start workers
        final WorkerImplFactory workerFactory = new WorkerImplFactory(CONFIG, Arrays.asList(QUEUE),
                new MapBasedJobFactory(map(entry(TestAction.class.getSimpleName(), TestAction.class))));
        final WorkerPool workerPool = new WorkerPool(workerFactory, 10);
        workerPool.run();

        // Start jobs
        enqueue();

        // Wait a few seconds then shutdown
        try { Thread.sleep(15000); } catch (Exception e){} // Give ourselves time to process
        CLIENT.end();
        try { workerPool.endAndJoin(true, 100); } catch (Exception e){ e.printStackTrace(); }
    }
View Full Code Here

TOP

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

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.