Package net.greghaines.jesque.worker

Examples of net.greghaines.jesque.worker.MapBasedJobFactory


    @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);
View Full Code Here


    }

    @Test
    public void testPauseAndShutdownCommands() {
        final Worker worker = new WorkerImpl(config, set(testQueue),
                new MapBasedJobFactory(map(entry("TestAction", TestAction.class))));
        final Admin admin = new AdminImpl(config);
        admin.setWorker(worker);

        final Thread workerThread = new Thread(worker);
        workerThread.start();
View Full Code Here

        new AdminImpl(CONFIG, set(ADMIN_CHANNEL), null, null);
    }

    @Test(expected=IllegalArgumentException.class)
    public void testConstructor_FourArg_NullJedis() {
        new AdminImpl(CONFIG, set(ADMIN_CHANNEL), new MapBasedJobFactory(map(
                entry("PauseCommand", PauseCommand.class),
                entry("ShutdownCommand", ShutdownCommand.class))), null);
    }
View Full Code Here

        templateValues.put("url", "http://localhost:90/confir");
        templateValues.put("fName", "RANGANATHAN");
        final Job job = new Job("SendMailJob", null, "mail@gmail.com", "REGISTRATION_MAIL_SUBJECT", true,
                "REGISTRATION_MAIL", templateValues);
        final Worker worker = new WorkerImpl(CONFIG, Arrays.asList(TEST_QUEUE),
                new MapBasedJobFactory(map(entry("SendMailJob", SendMailJob.class))));
        final Thread workerThread = new Thread(worker);
        workerThread.start();
        try {
            TestUtils.enqueueJobs(TEST_QUEUE, Arrays.asList(job), CONFIG);
        } finally {
View Full Code Here

    @Ignore
    public void issue28() throws InterruptedException {
        changeRedisTimeout(10);
        TestUtils.enqueueJobs("longRunning", Arrays.asList(new Job("LongRunningAction", 20 * 1000L)), config);
        final Worker worker2 = new WorkerImpl(config, Arrays.asList("longRunning"),
                new MapBasedJobFactory(map(entry("LongRunningAction", LongRunningAction.class))));
        final AtomicBoolean successRef = new AtomicBoolean(false);
        worker2.getWorkerEventEmitter().addListener(new WorkerListener() {
            @Override
            public void onEvent(final WorkerEvent event, final Worker worker, final String queue, final Job job,
                    final Object runner, final Object result, final Throwable t) {
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();
View Full Code Here

            jedis.quit();
        }

        // Create and start worker
        final Worker worker = new WorkerImpl(config, Arrays.asList(testQueue),
                new MapBasedJobFactory(map(entry("TestAction", TestAction.class))));
        final Thread workerThread = new Thread(worker);
        workerThread.start();
        try { // Wait a bit to ensure the worker had time to process the job
            Thread.sleep(500);
        } finally { // Stop the worker
View Full Code Here

    public void testNotInterrupted() throws InterruptedException, JsonProcessingException {
        final String queue = "foo";
        TestUtils.enqueueJobs(queue, Arrays.asList(sleepJob), config);

        final Worker worker = new WorkerImpl(config, Arrays.asList(queue),
                new MapBasedJobFactory(JesqueUtils.map(JesqueUtils.entry("SleepAction", SleepAction.class))));
        final Thread workerThread = new Thread(worker);
        workerThread.start();

        Thread.sleep(1000);
View Full Code Here

    public void testInterrupted() throws InterruptedException, JsonProcessingException {
        final String queue = "bar";
        TestUtils.enqueueJobs(queue, Arrays.asList(sleepJob), config);

        final Worker worker = new WorkerImpl(config, Arrays.asList(queue),
                new MapBasedJobFactory(JesqueUtils.map(JesqueUtils.entry("SleepAction", SleepAction.class))));
        final Thread workerThread = new Thread(worker);
        workerThread.start();

        TestUtils.stopWorker(worker, workerThread, true);
View Full Code Here

        String incorrectJson = "{";
        jedis.sadd(JesqueUtils.createKey(config.getNamespace(), QUEUES), queue);
        jedis.rpush(JesqueUtils.createKey(config.getNamespace(), QUEUE, queue), incorrectJson);

        final Worker worker = new WorkerImpl(config, Arrays.asList(queue),
                new MapBasedJobFactory(JesqueUtils.map(JesqueUtils.entry("SleepAction", SleepAction.class))));
        final Thread workerThread = new Thread(worker);
        workerThread.start();

        Thread.sleep(1000);
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.