Package com.hazelcast.transaction

Examples of com.hazelcast.transaction.TransactionContext.rollbackTransaction()


        try {
            final T value = task.execute(context);
            context.commitTransaction();
            return value;
        } catch (Throwable e) {
            context.rollbackTransaction();
            if (e instanceof TransactionException) {
                throw (TransactionException) e;
            }
            if (e.getCause() instanceof TransactionException) {
                throw (TransactionException) e.getCause();
View Full Code Here


                        });

                        if (exchange.getException() != null) {
                            // Rollback
                            if (transactionCtx != null) {
                                transactionCtx.rollbackTransaction();
                            }
                            getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
                        }

                    } catch (Exception e) {
View Full Code Here

                    } catch (Exception e) {
                        LOG.error("Hzlq Exception caught: " + e, e);
                        // Rollback
                        if (transactionCtx != null) {
                            log.trace("Rollback transaction: {}", transactionCtx.getTxnId());
                            transactionCtx.rollbackTransaction();
                        }
                    }
                }
                // It's OK, I commit
                if (exchange.getException() == null && transactionCtx != null) {
View Full Code Here

                continue;
            } catch (Throwable e) {
                // Rollback
                if (transactionCtx != null) {
                    log.trace("Rollback transaction: {}", transactionCtx.getTxnId());
                    transactionCtx.rollbackTransaction();
                }
                getExceptionHandler().handleException("Error processing exchange", exchange, e);
            }
        }
    }
View Full Code Here

                    tCtx.commitTransaction();
                    LOG.trace("Removed an exchange with ID {} for key {} in a thread-safe manner.", exchange.getExchangeId(), key);
                    LOG.trace("Put an exchange with ID {} for key {} into a recoverable storage in a thread-safe manner.",
                            exchange.getExchangeId(), key);
                } catch (Throwable throwable) {
                    tCtx.rollbackTransaction();

                    final String msg = String.format("Transaction with ID %s was rolled back for remove operation with a key %s and an Exchange ID %s.",
                            tCtx.getTxnId(), key, exchange.getExchangeId());
                    LOG.warn(msg, throwable);
                    throw new RuntimeException(msg, throwable);
View Full Code Here

        try {
            final T value = task.execute(context);
            context.commitTransaction();
            return value;
        } catch (Throwable e) {
            context.rollbackTransaction();
            if (e instanceof TransactionException) {
                throw (TransactionException) e;
            }
            if (e.getCause() instanceof TransactionException) {
                throw (TransactionException) e.getCause();
View Full Code Here

                        Collection<Object> values = multiMap.get(id);
                        assertFalse(values.isEmpty());
                        multiMap.remove(id);
                        tx.commitTransaction();
                    } catch (TransactionException e) {
                        tx.rollbackTransaction();
                        e.printStackTrace();
                    }
                } else {
                    LockSupport.parkNanos(100);
                }
View Full Code Here

                        TransactionalMultiMap<Object, Object> multiMap = tx.getMultiMap(name);
                        assertEquals(1, multiMap.valueCount(id));
                        multiMap.remove(id);
                        tx.commitTransaction();
                    } catch (TransactionException e) {
                        tx.rollbackTransaction();
                        e.printStackTrace();
                    }
                } else {
                    LockSupport.parkNanos(100);
                }
View Full Code Here

        final TransactionContext context = instance.newTransactionContext();
        context.beginTransaction();
        final TransactionalSet<Object> setTxn = context.getSet(setName);
        setTxn.add("itemWillGetRollBacked");
        context.rollbackTransaction();
        assertEquals(1, set.size());
    }
}
View Full Code Here

            assertTrue(q.offer("ali"));
            String s = q.poll();
            assertEquals("ali", s);
            context.commitTransaction();
        } catch (TransactionException e) {
            context.rollbackTransaction();
            throw e;
        }
        assertEquals(0, getQueue(instances, name).size());
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.