Package com.surftools.BeanstalkClient

Examples of com.surftools.BeanstalkClient.Job


      assertTrue(jobId > 0);
      jobIds[i] = jobId;
    }

    // peek 'em once
    Job job = null;
    for (int i = 0; i < nJobs; ++i) {
      job = client.peekReady();
      assertNotNull(job);
      assertEquals(jobIds[0], job.getJobId());
    }

    // reserve and delete
    for (int i = 0; i < nJobs; ++i) {
      job = client.reserve(null);
      assertNotNull(job);
      assertEquals(jobIds[i], job.getJobId());
      client.delete(job.getJobId());
    }

    // peek one last time
    for (int i = 0; i < nJobs; ++i) {
      job = client.peekReady();
View Full Code Here


    // note we adjust delay
    long jobId = client.put(65536, delaySeconds, 120, srcString.getBytes());
    assertTrue(jobId > 0);

    // peekDelayed
    Job job = client.peekDelayed();
    assertNotNull(job);
    assertEquals(jobId, job.getJobId());

    try {
      Thread.sleep(delaySeconds * 1000);
    } catch (Exception e) {

    }

    // reserve and delete
    job = client.reserve(null);
    assertNotNull(job);
    assertEquals(jobId, job.getJobId());
    client.delete(job.getJobId());

    // peek one last time
    job = client.peekDelayed();
    assertNull(job);

View Full Code Here

    client.useTube((String) tubeNames[1]);

    String srcString = "testPeekBuried";

    // peekBuried
    Job job = client.peekBuried();
    assertNull(job);

    // producer
    long jobId = client.put(65536, 0, 120, srcString.getBytes());
    assertTrue(jobId > 0);

    // peekBuried
    job = client.peekBuried();
    assertNull(job);

    // reserve and bury
    job = client.reserve(null);
    assertNotNull(job);
    assertEquals(jobId, job.getJobId());
    client.bury(job.getJobId(), 65536);

    // peekBuried
    job = client.peekBuried();
    assertNotNull(job);
    assertEquals(jobId, job.getJobId());

    // delete
    client.delete(jobId);

    // peekBuried
View Full Code Here

        client.useTube((String) tubeNames[1]);
        long jobId = client.put(65536, 0, 120, srcString.getBytes());
        assertTrue(jobId > 0);

        // consumer
        Job job = client.reserve(null);
        assertNotNull(job);
        long newJobId = job.getJobId();
        assertEquals(jobId, newJobId);

        String dstString = new String(job.getData());
        assertEquals(srcString, dstString);

        client.delete(job.getJobId());

        popWatchedTubes(client, tubeNames);

        client.close();
      }
View Full Code Here

    // note we adjust delay
    long jobId = client.put(65536, delaySeconds, 120, srcString.getBytes());
    assertTrue(jobId > 0);

    // peekReady (but we still can't reserve because of tube delay)
    Job job = client.peekReady();
    assertNotNull(job);
    assertEquals(jobId, job.getJobId());

    // reserve with timeout a little less than tube pause time
    job = client.reserve(tubeDelay - 1);
    assertNull(job);

    // now wait for tube to become un-paused
    job = client.reserve(2);
    assertNotNull(job);
    assertEquals(jobId, job.getJobId());

    popWatchedTubes(client, tubeNames);
  }
View Full Code Here

TOP

Related Classes of com.surftools.BeanstalkClient.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.