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);
}
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;
}
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;
}
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();
}
}
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);
}
Aggregations