Package net.greghaines.jesque

Examples of net.greghaines.jesque.JobFailure


    @Test
    public void serializeJobException() throws Exception {
        final Job job = new Job("TestAction", new Object[] { 1, 2.3, true, "test", Arrays.asList("inner", 4.5) });
        final Exception e = new Exception("Whoopie!");
        e.fillInStackTrace();
        final JobFailure jobFailure = new JobFailure();
        assertSerializeRoundTrip(jobFailure);
        jobFailure.setPayload(job);
        jobFailure.setFailedAt(new Date());
        jobFailure.setThrowable(e);
        jobFailure.setThrowableString(e.getClass().getName());
        jobFailure.setError(e.getMessage());
        jobFailure.setBacktrace(JesqueUtils.createBacktrace(e));
        jobFailure.setWorker("foo");
        assertSerializeRoundTrip(jobFailure);
    }
View Full Code Here


    @Test
    public void serializeJobError() throws Exception {
        final Job job = new Job("TestAction", new Object[] { 1, 2.3, true, "test", Arrays.asList("inner", 4.5) });
        final Error e = new Error("Whoopie!");
        e.fillInStackTrace();
        final JobFailure jobFailure = new JobFailure();
        assertSerializeRoundTrip(jobFailure);
        jobFailure.setPayload(job);
        jobFailure.setFailedAt(new Date());
        jobFailure.setThrowable(e);
        jobFailure.setThrowableString(e.getClass().getName());
        jobFailure.setError(e.getMessage());
        jobFailure.setBacktrace(JesqueUtils.createBacktrace(e));
        jobFailure.setWorker("foo");
        assertSerializeRoundTrip(jobFailure);
    }
View Full Code Here

    }

    @Test
    public void testDeseralize() throws Exception {
        final String payload = "{\"worker\":\"test5:12385-1:JAVA_DYNAMIC_QUEUES,SomeQueue\",\"queue\":\"audioTranscode\",\"payload\":{\"class\":\"SomeClass\",\"args\":[1234]},\"exception\":\"groovy.lang.MissingMethodException\",\"error\":\"SomeError\",\"backtrace\":[\"\\tat sompackage.someclass(somefile.java:42)\"],\"failed_at\":\"2011-10-17T18:01:33.185+0000\",\"retried_at\":null}";
        final JobFailure jobFailure = ObjectMapperFactory.get().readValue(payload, JobFailure.class);
        Assert.assertNull(jobFailure.getThrowable());
    }
View Full Code Here

    @Test
    public void testGetFailures() throws JsonProcessingException {
        final long offset = 4;
        final long count = 2;
        final List<JobFailure> origFailures = new ArrayList<JobFailure>(2);
        final JobFailure fail1 = new JobFailure();
        fail1.setError("foo");
        final JobFailure fail2 = new JobFailure();
        fail2.setError("bar");
        origFailures.add(fail1);
        origFailures.add(fail2);
        final List<String> origJsons = new ArrayList<String>(origFailures.size());
        for (final JobFailure fail : origFailures) {
            origJsons.add(ObjectMapperFactory.get().writeValueAsString(fail));
View Full Code Here

        final long index = 4;
        final long count = 1;
        final String queue = "queue1";
        final List<JobFailure> origFailures = new ArrayList<JobFailure>(1);
        final Job job = new Job("foo");
        final JobFailure fail1 = new JobFailure();
        fail1.setError("foo");
        fail1.setPayload(job);
        fail1.setQueue(queue);
        origFailures.add(fail1);
        final List<String> origJsons = new ArrayList<String>(origFailures.size());
        for (final JobFailure fail : origFailures) {
            origJsons.add(ObjectMapperFactory.get().writeValueAsString(fail));
        }
View Full Code Here

                 * {@inheritDoc}
                 */
                @Override
                public Date doWork(final Jedis jedis) throws Exception {
                    final Date retriedAt = new Date();
                    final JobFailure failure = failures.get(0);
                    failure.setRetriedAt(retriedAt);
                    jedis.lset(key(FAILED), index, ObjectMapperFactory.get().writeValueAsString(failure));
                    enqueue(jedis, failure.getQueue(), failure.getPayload());
                    return retriedAt;
                }
            });
        }
        return retryDate;
View Full Code Here

     * @return the JSON representation of a new JobFailure
     * @throws IOException
     *             if there was an error serializing the JobFailure
     */
    protected String failMsg(final Throwable t, final String queue, final Job job) throws IOException {
        final JobFailure failure = new JobFailure();
        failure.setFailedAt(new Date());
        failure.setWorker(this.name);
        failure.setQueue(queue);
        failure.setPayload(job);
        failure.setThrowable(t);
        return ObjectMapperFactory.get().writeValueAsString(failure);
    }
View Full Code Here

TOP

Related Classes of net.greghaines.jesque.JobFailure

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.