Search in sources :

Example 26 with BrokerException

use of com.sun.messaging.jmq.jmsserver.util.BrokerException in project openmq by eclipse-ee4j.

the class TransactionInformation method setAckBrokerAddress.

public synchronized void setAckBrokerAddress(SysMessageID sysid, ConsumerUID id, BrokerAddress addr) throws BrokerException {
    BrokerAddress ba = (BrokerAddress) sysidToAddr.get(sysid);
    if (ba != null && (!ba.equals(addr) || !ba.getBrokerSessionUID().equals(addr.getBrokerSessionUID()))) {
        BrokerException bex = new BrokerException("Message requeued:" + sysid, Status.GONE);
        bex.setRemoteConsumerUIDs(String.valueOf(id.longValue()));
        bex.setRemote(true);
        throw bex;
    }
    sysidToAddr.put(sysid, addr);
}
Also used : BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) BrokerAddress(com.sun.messaging.jmq.jmsserver.core.BrokerAddress)

Example 27 with BrokerException

use of com.sun.messaging.jmq.jmsserver.util.BrokerException in project openmq by eclipse-ee4j.

the class TransactionList method updateStatePrepareWithWork.

public TransactionState updateStatePrepareWithWork(TransactionUID tid, int state, boolean onephasePrepare, boolean persist) throws BrokerException {
    if (state != TransactionState.PREPARED) {
        throw new BrokerException("Unexpected call TransactionList.updateStatePrepareWithWork(tid=" + tid + ", " + TransactionState.toString(state) + ", " + onephasePrepare + ", " + persist + ")");
    }
    TransactionWork[] txnworks = getTransactionWork(tid);
    TransactionState ts = updateState(tid, state, TransactionState.NULL, onephasePrepare, TransactionState.NULL, persist, txnworks[0]);
    Iterator<TransactionWorkMessage> itr = txnworks[0].getSentMessages().iterator();
    while (itr.hasNext()) {
        PacketReference ref = itr.next().getPacketReference();
        ref.setIsStored();
    }
    return ts;
}
Also used : BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) PacketReference(com.sun.messaging.jmq.jmsserver.core.PacketReference)

Example 28 with BrokerException

use of com.sun.messaging.jmq.jmsserver.util.BrokerException in project openmq by eclipse-ee4j.

the class TransactionList method addTransactionID.

private TransactionInformation addTransactionID(TransactionUID id, TransactionState ts, boolean takeover, int type, boolean persist) throws BrokerException {
    JMQXid xid = ts.getXid();
    shareLock.lock();
    try {
        if (inuse_translist.contains(id)) {
            if (!takeover || type != TransactionInfo.TXN_CLUSTER || translist.containsKey(id) || !remoteTranslist.containsKey(id)) {
                throw new BrokerException(Globals.getBrokerResources().getKString(BrokerResources.X_TRANSACTIONID_INUSE, id.toString()), BrokerResources.X_TRANSACTIONID_INUSE, (Throwable) null, Status.CONFLICT);
            }
        }
        // If transaction is an XA (has an xid) save it for reverse mapping
        if (xid != null && xidTable.containsKey(xid)) {
            // Xid already in use
            throw new BrokerException(Globals.getBrokerResources().getKString(BrokerResources.X_TRANSACTIONID_INUSE, id.toString() + "[Xid=" + xid.toString() + "]"), BrokerResources.X_TRANSACTIONID_INUSE, (Throwable) null, Status.CONFLICT);
        }
    } finally {
        shareLock.unlock();
    }
    try {
        if (persist) {
            pstore.storeTransaction(id, ts, Destination.PERSIST_SYNC);
        }
    } catch (Exception ex) {
        throw new BrokerException(Globals.getBrokerResources().getKString(BrokerResources.X_TRANSACTION_STORE_ERROR, id.toString()), BrokerResources.X_TRANSACTION_STORE_ERROR, ex, Status.ERROR);
    }
    TransactionInformation ti = new TransactionInformation(id, ts);
    if (takeover) {
        ti.getTakeoverLock();
    }
    exclusiveLock.lock();
    try {
        inuse_translist.add(id);
        translist.put(id, ti);
        if (xid != null) {
            xidTable.put(xid, id);
        }
    } finally {
        exclusiveLock.unlock();
    }
    return ti;
}
Also used : BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) JMQXid(com.sun.messaging.jmq.util.JMQXid) IOException(java.io.IOException) LoadException(com.sun.messaging.jmq.jmsserver.persist.api.LoadException) UnknownTransactionException(com.sun.messaging.jmq.jmsserver.util.UnknownTransactionException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException)

Example 29 with BrokerException

use of com.sun.messaging.jmq.jmsserver.util.BrokerException in project openmq by eclipse-ee4j.

the class TransactionList method removeTransactionID.

private void removeTransactionID(TransactionUID id, boolean noremove, boolean fromReaper, boolean persist) throws BrokerException {
    TransactionState ts = null;
    TransactionInformation ti = null;
    shareLock.lock();
    try {
        ti = (TransactionInformation) translist.get(id);
    } finally {
        shareLock.unlock();
    }
    if (ti != null) {
        ts = ti.getState();
        if (!fromReaper && ts != null && ts.getState() == TransactionState.COMMITTED) {
            if (ti.getType() == TransactionInfo.TXN_CLUSTER) {
                ti.processed();
                txnReaper.addClusterTransaction(id, noremove);
                return;
            }
            if (ti.getType() == TransactionInfo.TXN_LOCAL) {
                ti.processed();
                if (noremove || TransactionList.TXN_REAPLIMIT > 0) {
                    txnReaper.addLocalTransaction(id, noremove);
                    return;
                }
            }
        }
    }
    if (!noremove && persist) {
        try {
            pstore.removeTransaction(id, true, false);
        } catch (IOException ex) {
            throw new BrokerException(Globals.getBrokerResources().getString(BrokerResources.X_INTERNAL_EXCEPTION, "Unable to remove the transaction id " + id), ex);
        }
    }
    exclusiveLock.lock();
    try {
        translist.remove(id);
        if (!remoteTranslist.containsKey(id)) {
            inuse_translist.remove(id);
        }
        // If XA (has Xid) remove it from reverse mapping
        if (ts != null && ts.getXid() != null) {
            xidTable.remove(ts.getXid());
        }
    } finally {
        exclusiveLock.unlock();
    }
}
Also used : BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) IOException(java.io.IOException)

Example 30 with BrokerException

use of com.sun.messaging.jmq.jmsserver.util.BrokerException in project openmq by eclipse-ee4j.

the class TransactionList method addMessage.

public void addMessage(PacketReference ref) throws BrokerException {
    TransactionUID tid = ref.getTransactionID();
    if (tid == null) {
        return;
    }
    SysMessageID sysid = ref.getSysMessageID();
    boolean delaypersist = false;
    if (ref.isPersistent() && !ref.getNeverStore() && Globals.isMinimumPersistLevel2()) {
        TransactionState ts = retrieveState(tid, true);
        if (ts == null) {
            throw new BrokerException(Globals.getBrokerResources().getKString(br.X_RECEIVED_MSG_WITH_UNKNOWN_TID, sysid, tid), Status.GONE);
        }
        if (ts.getType() != AutoRollbackType.NEVER) {
            delaypersist = true;
        }
    }
    if (Globals.isNewTxnLogEnabled()) {
        delaypersist = true;
    }
    if (!delaypersist) {
        ref.store();
    }
    addMessage(tid, sysid, false);
}
Also used : BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) SysMessageID(com.sun.messaging.jmq.io.SysMessageID)

Aggregations

BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)290 IOException (java.io.IOException)72 Destination (com.sun.messaging.jmq.jmsserver.core.Destination)33 PacketReference (com.sun.messaging.jmq.jmsserver.core.PacketReference)31 SizeString (com.sun.messaging.jmq.util.SizeString)31 ConsumerUID (com.sun.messaging.jmq.jmsserver.core.ConsumerUID)29 Iterator (java.util.Iterator)26 ArrayList (java.util.ArrayList)25 SelectorFormatException (com.sun.messaging.jmq.util.selector.SelectorFormatException)24 DestinationUID (com.sun.messaging.jmq.jmsserver.core.DestinationUID)23 HashMap (java.util.HashMap)22 SysMessageID (com.sun.messaging.jmq.io.SysMessageID)21 TransactionList (com.sun.messaging.jmq.jmsserver.data.TransactionList)21 LoadException (com.sun.messaging.jmq.jmsserver.persist.api.LoadException)21 Consumer (com.sun.messaging.jmq.jmsserver.core.Consumer)18 List (java.util.List)18 Packet (com.sun.messaging.jmq.io.Packet)16 BrokerAddress (com.sun.messaging.jmq.jmsserver.core.BrokerAddress)16 TransactionUID (com.sun.messaging.jmq.jmsserver.data.TransactionUID)16 ConsumerAlreadyAddedException (com.sun.messaging.jmq.jmsserver.util.ConsumerAlreadyAddedException)15