use of com.sun.messaging.bridge.service.jms.tx.BranchXid in project openmq by eclipse-ee4j.
the class JDBCTxLogImpl method logHeuristicBranch.
/**
* @param bxid the branch xid to update
* @param lr the LogRecord to identify the record to update
*/
@Override
public void logHeuristicBranch(BranchXid bxid, LogRecord lr) throws Exception {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "jdbcTxLog: log branch heuristic decision " + lr);
}
final GlobalXid gxid = lr.getGlobalXid();
final BranchXid branchXid = bxid;
final LogRecord newlr = lr;
super.checkClosedAndSetInProgress();
try {
UpdateOpaqueDataCallback callback = new UpdateOpaqueDataCallback() {
@Override
public Object update(Object currlr) throws Exception {
ObjectInputStream ois = new FilteringObjectInputStream(new ByteArrayInputStream((byte[]) currlr));
LogRecord oldlr = (LogRecord) ois.readObject();
if (oldlr == null) {
throw new IllegalArgumentException("Unexpected null current log record for " + gxid);
}
if (!oldlr.getGlobalXid().equals(gxid)) {
throw new IllegalArgumentException("Unexpected global xid " + oldlr.getGlobalXid() + " from store, expected:" + gxid);
}
ois.close();
if (oldlr.getBranchDecision(branchXid) == newlr.getBranchDecision(branchXid)) {
return currlr;
}
oldlr.setBranchDecision(branchXid, newlr.getBranchDecision(branchXid));
return oldlr;
}
};
_store.updateTMLogRecord(gxid.toString(), lr.toBytes(), _jmsbridge, callback, true, true, _logger);
} finally {
super.setInProgress(false);
}
}
Aggregations