Search in sources :

Example 41 with TransactionList

use of com.sun.messaging.jmq.jmsserver.data.TransactionList in project openmq by eclipse-ee4j.

the class TransactionManagerConfig method getNumTransactions.

public Integer getNumTransactions() {
    TransactionList[] tls = Globals.getDestinationList().getTransactionList(null);
    // PART
    TransactionList tl = tls[0];
    Vector transactions = tl.getTransactions(-1);
    return (Integer.valueOf(transactions.size()));
}
Also used : TransactionList(com.sun.messaging.jmq.jmsserver.data.TransactionList) Vector(java.util.Vector)

Example 42 with TransactionList

use of com.sun.messaging.jmq.jmsserver.data.TransactionList in project openmq by eclipse-ee4j.

the class TransactionManagerConfig method doRollbackCommit.

public void doRollbackCommit(String transactionID, boolean rollback) throws MBeanException {
    try {
        long longTid = 0;
        if (transactionID == null) {
            throw new Exception("Null transaction ID");
        }
        try {
            longTid = Long.parseLong(transactionID);
        } catch (Exception e) {
            throw new Exception("Invalid transaction ID: " + transactionID);
        }
        TransactionUID tid = new TransactionUID(longTid);
        TransactionList[] tls = Globals.getDestinationList().getTransactionList(null);
        TransactionList tl = null;
        TransactionState ts = null;
        for (int i = 0; i < tls.length; i++) {
            tl = tls[i];
            if (tl == null) {
                continue;
            }
            ts = tl.retrieveState(tid);
            if (ts == null) {
                continue;
            }
            break;
        }
        if (ts == null) {
            throw new Exception(rb.getString(rb.E_NO_SUCH_TRANSACTION, tid));
        }
        if (ts.getState() != TransactionState.PREPARED) {
            throw new Exception(rb.getString(rb.E_TRANSACTION_NOT_PREPARED, tid));
        }
        JMQXid xid = tl.UIDToXid(tid);
        if (xid == null) {
            throw new Exception(rb.getString(rb.E_INTERNAL_BROKER_ERROR, "Could not find Xid for " + tid));
        }
        PacketRouter pr = Globals.getPacketRouter(0);
        if (pr == null) {
            throw new Exception(rb.getString(rb.E_INTERNAL_BROKER_ERROR, "Could not locate Packet Router"));
        }
        TransactionHandler thandler = (TransactionHandler) pr.getHandler(PacketType.ROLLBACK_TRANSACTION);
        if (thandler == null) {
            throw new Exception(rb.getString(rb.E_INTERNAL_BROKER_ERROR, "Could not locate Transaction Handler"));
        }
        if (rollback) {
            thandler.doRollback(tl, tid, xid, null, ts, null, null, RollbackReason.ADMIN);
        } else {
            thandler.doCommit(tl, tid, xid, Integer.valueOf(XAResource.TMNOFLAGS), ts, null, false, null, null);
        }
    } catch (Exception e) {
        String opName;
        if (rollback) {
            opName = TransactionOperations.ROLLBACK;
        } else {
            opName = TransactionOperations.COMMIT;
        }
        handleOperationException(opName, e);
    }
}
Also used : TransactionUID(com.sun.messaging.jmq.jmsserver.data.TransactionUID) TransactionState(com.sun.messaging.jmq.jmsserver.data.TransactionState) PacketRouter(com.sun.messaging.jmq.jmsserver.data.PacketRouter) TransactionHandler(com.sun.messaging.jmq.jmsserver.data.handlers.TransactionHandler) TransactionList(com.sun.messaging.jmq.jmsserver.data.TransactionList) JMQXid(com.sun.messaging.jmq.util.JMQXid) MBeanException(javax.management.MBeanException)

Example 43 with TransactionList

use of com.sun.messaging.jmq.jmsserver.data.TransactionList in project openmq by eclipse-ee4j.

the class TransactionUtil method getUser.

public static String getUser(TransactionUID tid) {
    TransactionList[] tls = Globals.getDestinationList().getTransactionList(null);
    // PART
    TransactionList tl = tls[0];
    TransactionState ts;
    if (tl == null) {
        return (null);
    }
    ts = tl.retrieveState(tid);
    if (ts == null) {
        return (null);
    }
    return (ts.getUser());
}
Also used : TransactionState(com.sun.messaging.jmq.jmsserver.data.TransactionState) TransactionList(com.sun.messaging.jmq.jmsserver.data.TransactionList)

Example 44 with TransactionList

use of com.sun.messaging.jmq.jmsserver.data.TransactionList in project openmq by eclipse-ee4j.

the class TransactionUtil method getNumAcks.

public static Long getNumAcks(TransactionUID tid) {
    TransactionList[] tls = Globals.getDestinationList().getTransactionList(null);
    // PART
    TransactionList tl = tls[0];
    if (tl == null) {
        return (null);
    }
    return (Long.valueOf(tl.retrieveNConsumedMessages(tid)));
}
Also used : TransactionList(com.sun.messaging.jmq.jmsserver.data.TransactionList)

Example 45 with TransactionList

use of com.sun.messaging.jmq.jmsserver.data.TransactionList in project openmq by eclipse-ee4j.

the class TransactionUtil method getConnectionString.

public static String getConnectionString(TransactionUID tid) {
    TransactionList[] tls = Globals.getDestinationList().getTransactionList(null);
    // PART
    TransactionList tl = tls[0];
    TransactionState ts;
    if (tl == null) {
        return (null);
    }
    ts = tl.retrieveState(tid);
    if (ts == null) {
        return (null);
    }
    return (ts.getConnectionString());
}
Also used : TransactionState(com.sun.messaging.jmq.jmsserver.data.TransactionState) TransactionList(com.sun.messaging.jmq.jmsserver.data.TransactionList)

Aggregations

TransactionList (com.sun.messaging.jmq.jmsserver.data.TransactionList)48 TransactionState (com.sun.messaging.jmq.jmsserver.data.TransactionState)25 TransactionUID (com.sun.messaging.jmq.jmsserver.data.TransactionUID)23 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)23 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)10 ConsumerUID (com.sun.messaging.jmq.jmsserver.core.ConsumerUID)9 DestinationList (com.sun.messaging.jmq.jmsserver.core.DestinationList)9 PacketReference (com.sun.messaging.jmq.jmsserver.core.PacketReference)8 TransactionHandler (com.sun.messaging.jmq.jmsserver.data.handlers.TransactionHandler)8 List (java.util.List)8 PartitionedStore (com.sun.messaging.jmq.jmsserver.persist.api.PartitionedStore)7 IOException (java.io.IOException)7 TransactionBroker (com.sun.messaging.jmq.jmsserver.data.TransactionBroker)6 CacheHashMap (com.sun.messaging.jmq.util.CacheHashMap)6 JMQXid (com.sun.messaging.jmq.util.JMQXid)6 SelectorFormatException (com.sun.messaging.jmq.util.selector.SelectorFormatException)6 Iterator (java.util.Iterator)6 Map (java.util.Map)6 SysMessageID (com.sun.messaging.jmq.io.SysMessageID)5