コード例 #1
0
 @Test
 public void testTransactionalOfferAndPollWithTimeout() throws InterruptedException {
   final String item = "offered";
   final String name = randomString();
   final TransactionContext context = client.newTransactionContext();
   context.beginTransaction();
   TransactionalQueue<String> txnQueue = context.getQueue(name);
   assertTrue(txnQueue.offer(item));
   assertEquals(1, txnQueue.size());
   assertEquals(item, txnQueue.poll(5, TimeUnit.SECONDS));
   context.commitTransaction();
 }
コード例 #2
0
  @Test
  public void testTransactionalQueueSize() {
    final String item = "offered";
    final String name = randomString();
    final IQueue queue = client.getQueue(name);

    queue.offer(item);

    final TransactionContext context = client.newTransactionContext();
    context.beginTransaction();
    TransactionalQueue<String> txnQueue = context.getQueue(name);

    txnQueue.offer(item);
    assertEquals(2, txnQueue.size());

    context.rollbackTransaction();
  }