Package com.hazelcast.core

Examples of com.hazelcast.core.TransactionalQueue


        final HazelcastInstance instance1 = factory.newHazelcastInstance();
        final HazelcastInstance instance2 = factory.newHazelcastInstance();
        final TransactionContext context = instance1.newTransactionContext();
        context.beginTransaction();

        TransactionalQueue txnQ1 = context.getQueue("testQueuePollCommitSize");
        TransactionalQueue txnQ2 = context.getQueue("testQueuePollCommitSize");

        txnQ1.offer("item1");
        txnQ1.offer("item2");
        assertEquals(2, txnQ1.size());
        assertEquals(2, txnQ2.size());

        assertEquals("item1", txnQ1.poll());
        assertEquals(1, txnQ1.size());
        assertEquals(1, txnQ2.size());
        context.commitTransaction();

        assertEquals(1, instance1.getQueue("testQueuePollCommitSize").size());
        assertEquals(1, instance2.getQueue("testQueuePollCommitSize").size());
        assertEquals("item2", instance1.getQueue("testQueuePollCommitSize").poll());
View Full Code Here


        q.offer("item1");
        q.offer("item2");
        assertEquals(2, q.size());

        context.beginTransaction();
        TransactionalQueue txnQ1 = context.getQueue("testQueuePollRollbackSize");

        assertEquals("item1", txnQ1.poll());
        assertEquals(1, txnQ1.size());
        assertEquals(1, q.size());
        context.rollbackTransaction();
        assertEquals(2, q.size());
        assertEquals("item1", q.poll());
        assertEquals("item2", q.poll());
View Full Code Here

    @Override
    public Object innerCall() throws Exception {
        final ClientEndpoint endpoint = getEndpoint();
        final TransactionContext context = endpoint.getTransactionContext(txnId);
        final TransactionalQueue queue = context.getQueue(name);
        return queue.poll(timeout, TimeUnit.MILLISECONDS);
    }
View Full Code Here

TOP

Related Classes of com.hazelcast.core.TransactionalQueue

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.