{
checkXA();
if (rollbackOnly)
{
throw new XAException(XAException.XA_RBOTHER);
}
// Note - don't need to flush acks since the previous end would have
// done this
SessionXAPrepareMessage packet = new SessionXAPrepareMessage(xid);
try
{
SessionXAResponseMessage response = (SessionXAResponseMessage)channel.sendBlocking(packet);
if (response.isError())
{
throw new XAException(response.getResponseCode());
}
else
{
xaRetry = false;
return response.getResponseCode();
}
}
catch (HornetQException e)
{
if (e.getCode() == HornetQException.UNBLOCKED)
{
// Unblocked on failover
try
{
log.warn("failover occurred during prepare re-trying");
SessionXAResponseMessage response = (SessionXAResponseMessage)channel.sendBlocking(packet);
if (response.isError())
{
throw new XAException(response.getResponseCode());
}
else
{
xaRetry = false;
return response.getResponseCode();
}
}
catch (HornetQException e1)
{
// ignore and rollback
}
log.warn("failover occurred during prepare rolling back");
try
{
rollback(false);
}
catch (HornetQException e2)
{
throw new XAException(XAException.XAER_RMERR);
}
ClientSessionImpl.log.warn(e.getMessage(), e);
throw new XAException(XAException.XA_RBOTHER);
}
ClientSessionImpl.log.warn(e.getMessage(), e);
// This should never occur
throw new XAException(XAException.XAER_RMERR);
}
}