public JMSServiceReply prepareTransaction(long connectionId,
long transactionId, Xid xid) throws JMSServiceException {
JMSServiceReply reply;
HashMap props = new HashMap();
IMQConnection cxn;
TransactionUID txnUID = null;
JMQXid jmqXid = null;
Integer xaFlags = null;
cxn = checkConnectionId(connectionId, "prepareTransaction");
/*
* If transactionId is 0, extract it from XID
*/
if (transactionId == 0) {
jmqXid = new JMQXid(xid);
/*
xaFlags = new Integer(flags);
*/
txnUID = Globals.getTransactionList().xidToUID(jmqXid);
} else {
txnUID = new TransactionUID(transactionId);
}
try {
protocol.prepareTransaction(txnUID, xaFlags);
} catch(BrokerException be) {
String errStr = "prepareTransaction: prepare transaction failed. Connection ID: "
+ connectionId
+ ", Transaction ID: "
+ transactionId
+ ", XID: "
+ xid;
logger.logStack(Logger.ERROR, errStr, be);
props.put("JMQStatus", getErrorReplyStatus(be));
throw new JMSServiceException(errStr, be, props);
}
props.put("JMQStatus", JMSServiceReply.Status.OK);
props.put("JMQTransactionID", txnUID.longValue());
reply = new JMSServiceReply(props, null);
return (reply);
}