use of com.sun.messaging.jmq.jmsserver.data.TransactionWorkMessage in project openmq by eclipse-ee4j.
the class TransactionHandler method calculateStoredRouting.
private boolean calculateStoredRouting(PartitionedStore pstore, BaseTransaction baseTxn) throws BrokerException {
boolean sentMessagesNeedLogging = false;
// only need to log if message is persistent
TransactionWork txnWork = baseTxn.getTransactionWork();
List<TransactionWorkMessage> sentMessages = txnWork.getSentMessages();
if (sentMessages != null) {
Iterator<TransactionWorkMessage> iter = sentMessages.iterator();
while (iter.hasNext()) {
TransactionWorkMessage twm = iter.next();
sentMessagesNeedLogging |= calculateStoredRouting(pstore, twm);
}
}
boolean ackedMessagesNeedLogging = false;
List<TransactionWorkMessageAck> ackedMessages = txnWork.getMessageAcknowledgments();
if (ackedMessages != null) {
Iterator<TransactionWorkMessageAck> ackIter = ackedMessages.iterator();
while (ackIter.hasNext()) {
ackIter.next();
// TODO, check if ack needs logging
ackedMessagesNeedLogging |= true;
}
}
return ackedMessagesNeedLogging || sentMessagesNeedLogging;
}
use of com.sun.messaging.jmq.jmsserver.data.TransactionWorkMessage in project openmq by eclipse-ee4j.
the class TransactionLogReplayer method replaySentMessages.
private void replaySentMessages(List<TransactionWorkMessage> sentMessages, Set dstLoadedSet) throws IOException, BrokerException {
if (Store.getDEBUG()) {
logger.log(Logger.INFO, getPrefix() + " replaySentMessages");
}
for (int i = 0; i < sentMessages.size(); i++) {
TransactionWorkMessage workMessage = sentMessages.get(i);
replaySentMessage(workMessage, dstLoadedSet);
}
}
use of com.sun.messaging.jmq.jmsserver.data.TransactionWorkMessage in project openmq by eclipse-ee4j.
the class LoggedMessageHelper method messageListLogged.
void messageListLogged(List<TransactionWorkMessage> twms) {
Iterator<TransactionWorkMessage> iter = twms.iterator();
while (iter.hasNext()) {
TransactionWorkMessage twm = iter.next();
messageLogged(twm);
}
}
use of com.sun.messaging.jmq.jmsserver.data.TransactionWorkMessage in project openmq by eclipse-ee4j.
the class JDBCStore method updateTransactionStateWithWorkInternal.
public void updateTransactionStateWithWorkInternal(TransactionUID tid, TransactionState ts, TransactionWork txnwork, long storeSessionID, boolean sync) throws BrokerException {
if (tid == null || ts == null || txnwork == null) {
throw new NullPointerException();
}
if (DEBUG) {
logger.log(Logger.INFO, "JDBCStore.updateTransactionStateInternal(" + tid + ", " + ts + ", " + ", " + txnwork + ", " + sync + ")");
}
Connection conn = null;
Exception myex = null;
try {
conn = dbmgr.getConnection(false);
Util.RetryStrategy retry = null;
do {
boolean inside = false;
try {
Iterator<TransactionWorkMessage> itr1 = txnwork.getSentMessages().iterator();
while (itr1.hasNext()) {
TransactionWorkMessage txnmsg = itr1.next();
Packet m = txnmsg.getMessage();
if (m == null) {
continue;
}
inside = true;
daoFactory.getMessageDAO().insert(conn, txnmsg.getDestUID(), m, null, null, storeSessionID, m.getTimestamp(), true, false);
inside = false;
}
if (FI.FAULT_INJECTION) {
try {
FI.checkFaultAndThrowBrokerException(FaultInjection.FAULT_TXN_PERSIST_WORK_1_5, null);
} catch (BrokerException e) {
FI.unsetFault(FI.FAULT_TXN_PERSIST_WORK_1_5);
throw e;
}
}
List<TransactionWorkMessageAck> txnacks = txnwork.getMessageAcknowledgments();
if (txnacks != null) {
Iterator<TransactionWorkMessageAck> itr2 = txnacks.iterator();
while (itr2.hasNext()) {
TransactionWorkMessageAck txnack = itr2.next();
TransactionAcknowledgement ta = txnack.getTransactionAcknowledgement();
if (ta != null) {
inside = true;
daoFactory.getConsumerStateDAO().updateTransaction(conn, ta.getSysMessageID(), ta.getStoredConsumerUID(), tid);
inside = false;
}
}
}
inside = true;
daoFactory.getTransactionDAO().updateTransactionState(conn, tid, ts, false);
inside = false;
conn.commit();
return;
} catch (Exception e) {
if (!inside) {
try {
conn.rollback();
} catch (SQLException rbe) {
logger.logStack(Logger.WARNING, BrokerResources.X_DB_ROLLBACK_FAILED, rbe);
}
}
if (retry == null) {
retry = new Util.RetryStrategy();
}
try {
retry.assertShouldRetry(e, conn);
} catch (RetrySQLRecoverableException ee) {
try {
Util.close(null, null, conn, ee);
conn = dbmgr.getConnection(false);
} catch (Exception eee) {
logger.logStack(Logger.WARNING, eee.getMessage(), eee);
conn = null;
if (e instanceof BrokerException) {
throw (BrokerException) e;
}
throw new BrokerException(e.getMessage(), e);
}
}
}
} while (true);
} catch (BrokerException e) {
myex = e;
throw e;
} finally {
Util.close(null, null, conn, myex);
}
}
use of com.sun.messaging.jmq.jmsserver.data.TransactionWorkMessage in project openmq by eclipse-ee4j.
the class TransactionHandler method getTransactionWork2.
private TransactionWork getTransactionWork2(PartitionedStore pstore, List plist, HashMap cmap, HashMap sToCmap) {
TransactionWork txnWork = new TransactionWork();
// NB should we be checking for persistent messages?
for (int i = 0; plist != null && i < plist.size(); i++) {
SysMessageID sysid = (SysMessageID) plist.get(i);
PacketReference ref = DL.get(pstore, sysid);
if (ref == null) {
logger.log(Logger.WARNING, Globals.getBrokerResources().getKString(BrokerResources.W_MSG_REMOVED_BEFORE_SENDER_COMMIT, sysid));
continue;
}
try {
if (ref.isPersistent()) {
TransactionWorkMessage txnWorkMessage = new TransactionWorkMessage();
Destination dest = ref.getDestination();
txnWorkMessage.setDestUID(dest.getDestinationUID());
txnWorkMessage.setPacketReference(ref);
txnWork.addMessage(txnWorkMessage);
}
} catch (Exception ex) {
logger.logStack((BrokerStateHandler.isShuttingDown() ? Logger.DEBUG : Logger.ERROR), BrokerResources.E_INTERNAL_BROKER_ERROR, "unable to log transaction message " + sysid, ex);
}
}
// iterate over messages consumed in this transaction
if (cmap != null && cmap.size() > 0) {
Iterator itr = cmap.entrySet().iterator();
while (itr.hasNext()) {
Map.Entry entry = (Map.Entry) itr.next();
SysMessageID sysid = (SysMessageID) entry.getKey();
List interests = (List) entry.getValue();
if (sysid == null) {
continue;
}
PacketReference ref = DL.get(null, sysid);
if (ref == null || ref.isDestroyed() || ref.isInvalid()) {
// already been deleted .. ignore
continue;
}
// The cluster txn should only need op store the addresses of the brokers involved.
if (!ref.isLocal()) {
continue;
}
Destination[] ds = DL.getDestination(ref.getPartitionedStore(), ref.getDestinationUID());
Destination dst = ds[0];
// - hence the list.
for (int i = 0; i < interests.size(); i++) {
ConsumerUID intid = (ConsumerUID) interests.get(i);
ConsumerUID sid = (ConsumerUID) sToCmap.get(intid);
if (sid == null) {
sid = intid;
}
try {
// ignore non-durable subscriber
if (!dst.isQueue() && !sid.shouldStore()) {
continue;
}
if (ref.isPersistent()) {
TransactionWorkMessageAck ack = new TransactionWorkMessageAck();
ack.setConsumerID(sid);
ack.setDest(dst.getDestinationUID());
ack.setSysMessageID(sysid);
txnWork.addMessageAcknowledgement(ack);
}
} catch (Exception ex) {
logger.logStack(Logger.ERROR, BrokerResources.E_INTERNAL_BROKER_ERROR, " unable to log transaction message acknowledgement " + sysid + ":" + intid, ex);
}
}
}
}
return txnWork;
}
Aggregations