Package net.greghaines.jesque

Examples of net.greghaines.jesque.Job


    public void testRequeue() throws JsonProcessingException {
        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);
View Full Code Here


    /**
     * {@inheritDoc}
     */
    @Override
    public void shutdownWorkers(final boolean now) {
        publish(new Job("ShutdownCommand", now));
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public void shutdownWorkers(final String channel, final boolean now) {
        publish(channel, new Job("ShutdownCommand", now));
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public void togglePausedWorkers(final boolean paused) {
        publish(new Job("PauseCommand", paused));
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public void togglePausedWorkers(final String channel, final boolean paused) {
        publish(channel, new Job("PauseCommand", paused));
    }
View Full Code Here

                    // Might have been waiting in poll()/checkPaused() for a while
                    if (RUNNING.equals(this.state.get())) {
                        this.listenerDelegate.fireEvent(WORKER_POLL, this, curQueue, null, null, null, null);
                        final String payload = pop(curQueue);
                        if (payload != null) {
                            final Job job = ObjectMapperFactory.get().readValue(payload, Job.class);
                            process(job, curQueue);
                            missCount = 0;
                        } else if (++missCount >= this.queueNames.size() && RUNNING.equals(this.state.get())) {
                            // Keeps worker from busy-spinning on empty queues
                            missCount = 0;
View Full Code Here

        @Override
        public void onMessage(final String channel, final String message) {
            if (message != null) {
                try {
                    AdminImpl.this.processingJob.set(true);
                    final Job job = ObjectMapperFactory.get().readValue(message, Job.class);
                    execute(job, channel, AdminImpl.this.jobFactory.materializeJob(job));
                } catch (Exception e) {
                    recoverFromException(channel, e);
                } finally {
                    AdminImpl.this.processingJob.set(false);
View Full Code Here

  @Test
  public void shouldAddJob() {
    worker.togglePause(true);
    Assert.assertEquals(0, queueInfoDAO.getPendingCount());
    MockJob.JOB_COUNT = 0;
    Job job = new Job(MockJob.class.getName(), new Object[]{});
    for (int i = 1; i <= 5; i++) {
      jesqueClient.enqueue("JESQUE_QUEUE", job);
      Assert.assertEquals(i, queueInfoDAO.getPendingCount());
    }
    worker.togglePause(false);
View Full Code Here

  @Test
  public void shouldProcessJobsByClass() {
    worker.togglePause(true);
    Assert.assertEquals(0, queueInfoDAO.getPendingCount());
    MockJob.JOB_COUNT = 0;
    Job job = new Job(MockJob.class.getName(), new Object[]{});
    for (int i = 1; i <= 5; i++) {
      jesqueClient.enqueue("JESQUE_QUEUE", job);
    }
    worker.togglePause(false);
    waitJob(5000);
View Full Code Here

  @Test
  public void shouldProcessJobsByBeanId() {
    worker.togglePause(true);
    Assert.assertEquals(0, queueInfoDAO.getPendingCount());
    MockJob.JOB_COUNT = 0;
    Job job = new Job("mockJob", new Object[]{});
    for (int i = 1; i <= 5; i++) {
      jesqueClient.enqueue("JESQUE_QUEUE", job);
    }
    worker.togglePause(false);
    waitJob(5000);
View Full Code Here

TOP

Related Classes of net.greghaines.jesque.Job

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.