use of com.sun.messaging.jmq.io.Packet in project openmq by eclipse-ee4j.
the class Destination method markDead.
/**
* place the message in the DMQ.
* <P>
* called from Destination and Consumer.
*/
private void markDead(PacketReference pr, Reason reason, Hashtable props) throws BrokerException {
Packet p = pr.getPacket();
if (p == null) {
logger.log(Logger.DEBUG, "Internal Error: null packet for DMQ");
return;
}
Hashtable packetProps = null;
try {
packetProps = p.getProperties();
if (packetProps == null) {
packetProps = new Hashtable();
}
} catch (Exception ex) {
logger.logStack(Logger.DEBUG, "could not get props ", ex);
packetProps = new Hashtable();
}
boolean useVerbose = false;
Object o = packetProps.get(DMQ.VERBOSE);
if (o != null) {
if (o instanceof Boolean) {
useVerbose = ((Boolean) o).booleanValue();
} else if (o instanceof String) {
useVerbose = Boolean.parseBoolean((String) o);
} else {
logger.log(Logger.WARNING, BrokerResources.E_INTERNAL_BROKER_ERROR, "Unknown type for verbose " + o.getClass());
useVerbose = DL.getVerbose();
}
} else {
useVerbose = DL.getVerbose();
}
if (isDMQ) {
if (getDEBUG() || useVerbose) {
logger.log(Logger.INFO, BrokerResources.I_DMQ_REMOVING_DMQ_MSG, pr.getSysMessageID(), DestinationUID.getUID(p.getDestination(), p.getIsQueue()).toString());
}
return;
}
// OK deal with various flags
boolean useDMQforMsg = false;
o = packetProps.get(DMQ.PRESERVE_UNDELIVERED);
if (o != null) {
if (o instanceof Boolean) {
useDMQforMsg = ((Boolean) o).booleanValue();
} else if (o instanceof String) {
useDMQforMsg = Boolean.parseBoolean((String) o);
} else {
logger.log(Logger.WARNING, BrokerResources.E_INTERNAL_BROKER_ERROR, "Unknown type for preserve undelivered " + o.getClass());
useDMQforMsg = useDMQ;
}
} else {
useDMQforMsg = useDMQ;
}
long receivedTime = pr.getTime();
long senderTime = pr.getTimestamp();
long expiredTime = pr.getExpireTime();
if (!useDMQforMsg) {
if (getDEBUG() || useVerbose) {
String[] args = { pr.getSysMessageID().toString(), pr.getDestinationUID().toString(), lookupReasonString(reason, receivedTime, expiredTime, senderTime) };
logger.log(Logger.INFO, BrokerResources.I_DMQ_REMOVING_MSG, args);
}
if (!pr.isLocal()) {
boolean waitack = !pr.isNoAckRemoteConsumers();
Globals.getClusterBroadcast().acknowledgeMessage(pr.getBrokerAddress(), pr.getSysMessageID(), pr.getQueueUID(), ClusterBroadcast.MSG_DEAD, props, waitack);
}
return;
}
boolean truncateBody = false;
o = packetProps.get(DMQ.TRUNCATE_BODY);
if (o != null) {
if (o instanceof Boolean) {
truncateBody = ((Boolean) o).booleanValue();
} else if (o instanceof String) {
truncateBody = Boolean.parseBoolean((String) o);
} else {
logger.log(Logger.WARNING, BrokerResources.E_INTERNAL_BROKER_ERROR, "Unknown type for preserve undelivered " + o.getClass());
truncateBody = !DL.getStoreBodyInDMQ();
}
} else {
truncateBody = !DL.getStoreBodyInDMQ();
}
if (props == null) {
props = new Hashtable();
}
Integer cnt = (Integer) props.remove(TEMP_CNT);
if (cnt != null) {
// set as a header property
props.put(DMQ.DELIVERY_COUNT, cnt);
} else {
// total deliver cnt ?
}
if (pr.isLocal()) {
props.putAll(packetProps);
} else {
// reason for the other side
props.put("REASON", Integer.valueOf(reason.intValue()));
}
if (props.get(DMQ.UNDELIVERED_COMMENT) == null) {
props.put(DMQ.UNDELIVERED_COMMENT, lookupReasonString(reason, receivedTime, expiredTime, senderTime));
}
props.put(DMQ.UNDELIVERED_TIMESTAMP, Long.valueOf(System.currentTimeMillis()));
props.put(DMQ.BODY_TRUNCATED, Boolean.valueOf(truncateBody));
if (reason == RemoveReason.EXPIRED || reason == RemoveReason.EXPIRED_BY_CLIENT || reason == RemoveReason.EXPIRED_ON_DELIVERY) {
props.put(DMQ.UNDELIVERED_REASON, DMQ.REASON_EXPIRED);
} else if (reason == RemoveReason.REMOVED_LOW_PRIORITY) {
props.put(DMQ.UNDELIVERED_REASON, DMQ.REASON_LOW_PRIORITY);
} else if (reason == RemoveReason.REMOVED_OLDEST) {
props.put(DMQ.UNDELIVERED_REASON, DMQ.REASON_OLDEST);
} else if (reason == RemoveReason.UNDELIVERABLE) {
props.put(DMQ.UNDELIVERED_REASON, DMQ.REASON_UNDELIVERABLE);
} else {
props.put(DMQ.UNDELIVERED_REASON, DMQ.REASON_ERROR);
}
if (pr.getBrokerAddress() != null) {
props.put(DMQ.BROKER, pr.getBrokerAddress().toString());
} else {
props.put(DMQ.BROKER, Globals.getMyAddress().toString());
}
String deadbkr = (String) packetProps.get(DMQ.DEAD_BROKER);
if (deadbkr != null) {
props.put(DMQ.DEAD_BROKER, deadbkr);
} else {
props.put(DMQ.DEAD_BROKER, Globals.getMyAddress().toString());
}
if (!pr.isLocal()) {
boolean waitack = !pr.isNoAckRemoteConsumers();
Globals.getClusterBroadcast().acknowledgeMessage(pr.getBrokerAddress(), pr.getSysMessageID(), pr.getQueueUID(), ClusterBroadcast.MSG_DEAD, props, waitack);
// done
return;
}
// OK ... now create the packet
Packet newp = new Packet();
// first make sure we have the room to put it on the
// queue ... if we dont, an exception will be thrown
// from queue Message
PacketReference ref = null;
try {
newp.generateSequenceNumber(false);
newp.generateTimestamp(false);
newp.fill(p);
newp.setProperties(props);
if (truncateBody) {
newp.setMessageBody(new byte[0]);
}
Queue dmq = DL.getDMQ();
ref = PacketReference.createReference(pstore, newp, dmq.getDestinationUID(), null);
ref.overrideExpireTime(0);
ref.clearExpireInfo();
ref.clearDeliveryTimeInfo();
ref.setTimestamp(System.currentTimeMillis());
synchronized (dmq) {
ref.setSequence(dmq.seqCnt++);
}
DL.routeMoveAndForwardMessage(pr, ref, dmq);
} catch (Exception ex) {
// depending on the type, we either ignore or throw out
if (reason == RemoveReason.UNDELIVERABLE || reason == RemoveReason.ERROR) {
if (ex instanceof BrokerException) {
throw (BrokerException) ex;
}
throw new BrokerException(br.getKString(BrokerResources.X_DMQ_MOVE_INVALID), ex);
}
if (getDEBUG() || useVerbose) {
logger.logStack(Logger.WARNING, BrokerResources.W_DMQ_ADD_FAILURE, pr.getSysMessageID().toString(), ex);
}
}
if ((getDEBUG() || useVerbose) && useDMQforMsg) {
String[] args = { pr.getSysMessageID().toString(), pr.getDestinationUID().toString(), lookupReasonString(reason, receivedTime, expiredTime, senderTime) };
logger.log(Logger.INFO, BrokerResources.I_DMQ_MOVING_TO_DMQ, args);
}
ref.unload();
}
use of com.sun.messaging.jmq.io.Packet in project openmq by eclipse-ee4j.
the class Destination method load.
public synchronized LinkedHashMap load(boolean neverExpire, Map preparedAcks, Map transactionStates, Map committingTrans, Set takeoverMsgs, boolean noerrnotfound) throws BrokerException {
if (Globals.getStore().getPartitionModeEnabled() && takeoverMsgs != null) {
String emsg = br.getKString(br.E_INTERNAL_BROKER_ERROR, ": Unexpected call:Destination.load(takeoverMsgs) for partition mode");
BrokerException ex = new BrokerException(emsg);
logger.logStack(logger.ERROR, emsg, ex);
throw ex;
}
if (loaded) {
return null;
}
logger.log(Logger.INFO, br.getKString(br.I_LOADING_DESTINATION, toString(), String.valueOf(size)) + logsuffix);
LinkedHashMap preparedTrans = null;
boolean enforceLimit = true;
Set deadMsgs = new HashSet();
int maxloadcnt = size;
int curcnt = 0;
try {
enforceLimit = destMessages.getEnforceLimits();
destMessages.enforceLimits(false);
Enumeration msgs = null;
try {
msgs = pstore.messageEnumeration(this);
} catch (DestinationNotFoundException e) {
if (noerrnotfound) {
logger.log(Logger.INFO, br.getKString(BrokerResources.I_LOAD_DST_NOTFOUND_INSTORE, getName(), e.getMessage()));
return null;
}
throw e;
}
MessageDeliveryTimeTimer dt = deliveryTimeTimer;
SortedSet s = null;
try {
// no other store access should occur in this block
HAMonitorService haMonitor = Globals.getHAMonitorService();
boolean takingoverCheck = (takeoverMsgs == null && !Globals.getStore().getPartitionModeEnabled() && Globals.getHAEnabled() && haMonitor != null && haMonitor.checkTakingoverDestination(this));
if (dt == null && !isDMQ()) {
if (!isValid()) {
String emsg = br.getKString(br.X_LOAD_MSGS_TO_DESTROYED_DST, getDestinationUID());
logger.log(logger.WARNING, emsg);
throw new BrokerException(emsg);
}
String emsg = br.getKString(br.X_LOAD_MSGS_TO_DST_NO_DELIVERY_TIMER, getDestinationUID());
logger.log(logger.WARNING, emsg);
throw new BrokerException(emsg);
}
s = new TreeSet(new RefCompare());
while (msgs.hasMoreElements()) {
Packet p = (Packet) msgs.nextElement();
PacketReference pr = PacketReference.createReference(pstore, p, uid, null);
if (isDMQ()) {
pr.clearDeliveryTimeInfo();
}
if (takeoverMsgs != null && takeoverMsgs.contains(pr)) {
pr = null;
continue;
}
if (takingoverCheck && haMonitor.checkTakingoverMessage(p)) {
pr = null;
continue;
}
MessageDeliveryTimeInfo di = pr.getDeliveryTimeInfo();
if (di != null) {
dt.removeMessage(di);
}
if (neverExpire) {
pr.overrideExpireTime(0);
}
// mark already stored and make packet a SoftReference to
// prevent running out of memory if dest has lots of msgs
pr.setLoaded();
if (getDEBUG()) {
logger.log(Logger.INFO, "Loaded Message " + p + " into destination " + this);
}
try {
if (!isDMQ && !DL.addNewMessage(false, pr).getReturn()) {
// expired
deadMsgs.add(pr);
}
} catch (Exception ex) {
String[] args = { pr.getSysMessageID().toString(), pr.getDestinationUID().toString(), ex.getMessage() };
logger.logStack(Logger.WARNING, BrokerResources.W_CAN_NOT_LOAD_MSG, args, ex);
continue;
}
s.add(pr);
DL.packetlistAdd(pr.getSysMessageID(), pr.getDestinationUID(), null);
curcnt++;
if (curcnt > 0 && (curcnt % LOAD_COUNT == 0 || (curcnt > LOAD_COUNT && curcnt == size))) {
String[] args = { toString(), String.valueOf(curcnt), String.valueOf(maxloadcnt), String.valueOf((curcnt * 100) / maxloadcnt) };
logger.log(Logger.INFO, BrokerResources.I_LOADING_DEST_IN_PROCESS, args);
}
}
} finally {
pstore.closeEnumeration(msgs);
}
if (FaultInjection.getInjection().FAULT_INJECTION) {
FaultInjection fi = FaultInjection.getInjection();
try {
fi.checkFaultAndThrowBrokerException(FaultInjection.FAULT_LOAD_DST_1_5, null);
} catch (BrokerException e) {
fi.unsetFault(fi.FAULT_LOAD_DST_1_5);
throw e;
}
}
// now we're sorted, process
Iterator itr = s.iterator();
while (itr.hasNext()) {
PacketReference pr = (PacketReference) itr.next();
// ok .. see if we need to remove the message
ConsumerUID[] consumers = pstore.getConsumerUIDs(getDestinationUID(), pr.getSysMessageID());
if (consumers == null) {
consumers = new ConsumerUID[0];
}
if (getDEBUG()) {
logger.log(Logger.INFO, consumers.length + " stored consumers for " + pr + ":" + getDestinationUID());
}
if (consumers.length == 0 && pstore.hasMessageBeenAcked(uid, pr.getSysMessageID())) {
if (getDEBUG()) {
logger.log(Logger.INFO, "Message " + pr.getSysMessageID() + "[" + this + "] has been acked, destory..");
}
decrementDestinationSize(pr);
DL.removePacketList(pr.getSysMessageID(), pr.getDestinationUID(), pr);
pr.destroy();
continue;
}
if (consumers.length > 0) {
pr.setStoredWithInterest(true);
} else {
pr.setStoredWithInterest(false);
}
// first producer side transactions
MessageDeliveryTimeInfo di = pr.getDeliveryTimeInfo();
boolean dontRoute = false;
boolean delayDelivery = false;
if (di != null && !di.isDeliveryDue()) {
dt.addMessage(di);
delayDelivery = true;
dontRoute = true;
}
TransactionUID sendtid = pr.getTransactionID();
if (sendtid != null) {
// if unrouted and not in rollback -> remove
Boolean state = (Boolean) (transactionStates == null ? null : transactionStates.get(sendtid));
// at this point, we should be down to 3 states
if (state == null) {
if (consumers.length == 0 && !delayDelivery) {
// message
try {
consumers = routeLoadedTransactionMessage(pr);
} catch (Exception ex) {
logger.logStack(Logger.WARNING, br.getKString(br.W_EXCEPTION_ROUTE_LOADED_MSG, pr.getSysMessageID(), ex.getMessage()), ex);
}
if (consumers.length > 0) {
int[] states = new int[consumers.length];
for (int i = 0; i < states.length; i++) {
states[i] = PartitionedStore.INTEREST_STATE_ROUTED;
}
try {
pstore.storeInterestStates(getDestinationUID(), pr.getSysMessageID(), consumers, states, true, null);
pr.setStoredWithInterest(true);
} catch (Exception ex) {
// ok .. maybe weve already been routed
}
} else {
if (getDEBUG()) {
logger.log(Logger.INFO, "Message " + pr.getSysMessageID() + " [TUID=" + pr.getTransactionID() + ", " + this + "] no interest" + ", destroy...");
}
decrementDestinationSize(pr);
DL.removePacketList(pr.getSysMessageID(), pr.getDestinationUID(), pr);
pr.destroy();
continue;
}
}
} else if (state.equals(Boolean.TRUE)) {
if (preparedTrans == null) {
preparedTrans = new LinkedHashMap();
}
preparedTrans.put(pr.getSysMessageID(), pr.getTransactionID());
dontRoute = true;
} else {
// rolledback
if (getDEBUG()) {
logger.log(Logger.INFO, "Message " + pr.getSysMessageID() + " [TUID=" + pr.getTransactionID() + ", " + this + "] to be rolled back" + ", destroy...");
}
decrementDestinationSize(pr);
DL.removePacketList(pr.getSysMessageID(), pr.getDestinationUID(), pr);
pr.destroy();
continue;
}
}
if (consumers.length == 0 && !dontRoute) {
if (getDEBUG()) {
logger.log(Logger.INFO, "No consumer and dontRoute: Unrouted packet " + pr + ", " + this);
}
decrementDestinationSize(pr);
DL.removePacketList(pr.getSysMessageID(), pr.getDestinationUID(), pr);
pr.destroy();
continue;
}
int[] states = new int[consumers.length];
for (int i = 0; i < consumers.length; i++) {
states[i] = pstore.getInterestState(getDestinationUID(), pr.getSysMessageID(), consumers[i]);
}
if (consumers.length > 0) {
pr.update(consumers, states);
}
try {
putMessage(pr, AddReason.LOADED);
} catch (IllegalStateException | OutOfLimitsException ex) {
String[] args = { pr.getSysMessageID().toString(), pr.getDestinationUID().toString(), ex.getMessage() };
logger.logStack(Logger.WARNING, BrokerResources.W_CAN_NOT_LOAD_MSG, args, ex);
continue;
}
ExpirationInfo ei = pr.getExpireInfo();
if (ei != null && expireReaper != null) {
expireReaper.addExpiringMessage(ei);
}
List<ConsumerUID> consumerList = Arrays.asList(consumers);
// now, deal with consumer side transactions
Map transCidToState = (Map) (preparedAcks == null ? null : preparedAcks.get(pr.getSysMessageID()));
if (transCidToState != null) {
// ok .. this isnt code focused on performance, but
// its rarely called and only once
// new a new list that allows itr.remove()
consumerList = new ArrayList<>(consumerList);
Iterator citr = consumerList.iterator();
while (citr.hasNext()) {
ConsumerUID cuid = (ConsumerUID) citr.next();
TransactionUID tid = (TransactionUID) transCidToState.get(cuid);
Boolean state = Boolean.FALSE;
if (tid != null) {
state = (Boolean) (transactionStates == null ? null : transactionStates.get(tid));
}
// OK for committed transactions, acknowledge
if (state == null) {
if (getDEBUG()) {
logger.log(Logger.INFO, "Consumed message has committed state " + pr.getSysMessageID() + " [TUID=" + tid + ", " + this + "]" + ", consumer: " + cuid);
}
// acknowledge
if (pr.acknowledged(cuid, cuid, false, true)) {
if (committingTrans != null && committingTrans.get(tid) != null) {
unputMessage(pr, RemoveReason.ACKNOWLEDGED);
}
decrementDestinationSize(pr);
DL.removePacketList(pr.getSysMessageID(), pr.getDestinationUID(), pr);
pr.destroy();
if (getDEBUG()) {
logger.log(Logger.INFO, "Remove committed consumed message " + pr.getSysMessageID() + " [TUID=" + tid + ", " + this + "]" + ", consumer: " + cuid);
}
}
citr.remove();
continue;
} else if (state.equals(Boolean.TRUE)) {
// for prepared transactions, dont route
citr.remove();
} else if (state.equals(Boolean.FALSE)) {
// for rolled back transactions, do nothing
if (getDEBUG()) {
logger.log(Logger.INFO, "Redeliver message " + pr.getSysMessageID() + " [TUID=" + tid + ", " + this + "]" + " to consumer " + cuid);
}
}
}
// done processing acks
}
// dont recurse
loaded = true;
if (!dontRoute) {
if (getDEBUG()) {
logger.log(Logger.INFO, "Route loaded message " + pr.getSysMessageID() + " [" + this + "]" + " to consumers " + consumerList);
}
if (di != null) {
forwardDeliveryDelayedMessage(new HashSet<>(consumerList), pr);
} else {
routeLoadedMessage(pr, consumerList);
}
} else if (delayDelivery) {
di.setDeliveryReady();
}
}
} catch (Throwable ex) {
String emsg = Globals.getBrokerResources().getKString(BrokerResources.W_LOAD_DST_FAIL, getName());
logger.logStack(Logger.ERROR, emsg, ex);
loaded = true;
unload(true);
throw new BrokerException(emsg, ex);
}
destMessages.enforceLimits(enforceLimit);
loaded = true;
// clean up dead messages
Iterator deaditr = deadMsgs.iterator();
while (deaditr.hasNext()) {
PacketReference pr = (PacketReference) deaditr.next();
try {
if (preparedTrans != null) {
preparedTrans.remove(pr.getSysMessageID());
}
removeMessage(pr.getSysMessageID(), RemoveReason.EXPIRED);
} catch (Exception ex) {
logger.logStack(Logger.INFO, BrokerResources.E_INTERNAL_BROKER_ERROR, "Processing " + pr + " while loading destination " + this, ex);
}
}
logger.log(Logger.INFO, br.getKString(br.I_LOADING_DEST_COMPLETE, toString(), String.valueOf(size)) + logsuffix);
return preparedTrans;
}
use of com.sun.messaging.jmq.io.Packet in project openmq by eclipse-ee4j.
the class ProtocolImpl method deliver.
/**
* mimics the behavior of DELIVER
* <P>
* Packet:<B>DELIVER</b>
* </p>
*
* @param cid consumer id to attach to the messages
* @param ids a list of id's to deliver
* @return an ArrayList of packets
*/
@Override
public ArrayList deliver(long cid, ArrayList ids) throws BrokerException, IOException {
ArrayList returnlist = new ArrayList();
Iterator itr = ids.iterator();
while (itr.hasNext()) {
SysMessageID id = (SysMessageID) itr.next();
PacketReference ref = DL.get(null, id);
if (ref == null) {
continue;
}
Packet realp = ref.getPacket();
if (ref.isInvalid()) {
continue;
}
Packet p = new Packet(false);
p.fill(realp);
p.setConsumerID(cid);
returnlist.add(p);
}
return returnlist;
}
use of com.sun.messaging.jmq.io.Packet in project openmq by eclipse-ee4j.
the class MessageDAOImpl method getDebugInfo.
/**
* Get debug information about the store.
*
* @param conn database connection
* @return A HashMap of name value pair of information
*/
@Override
public HashMap getDebugInfo(Connection conn) {
if (!Boolean.getBoolean(getTableName())) {
return super.getDebugInfo(conn);
}
HashMap map = new LinkedHashMap();
HashMap baddata = new LinkedHashMap();
String brokerid = null;
Object data = null;
try {
brokerid = DBManager.getDBManager().getBrokerID();
data = getMsgIDsAndDstIDsByBroker(null, brokerid);
map.put("[" + tableName + "]RowCount(brokerID=" + brokerid + ")", String.valueOf(((Map) data).size()));
String sysid = null;
Iterator itr = ((Map) data).keySet().iterator();
while (itr.hasNext()) {
sysid = (String) itr.next();
String dst = (String) ((Map) data).get(sysid);
boolean bad = false;
try {
SysMessageID.get(sysid);
} catch (RuntimeException e) {
bad = true;
baddata.put("EXCEPTION-MESSAGE_ID[" + sysid + "]", dst);
logger.logStack(logger.ERROR, "Failed to validate SysMessageID for message ID=" + sysid + " in destination " + dst + ": " + e.getMessage(), e);
}
try {
Packet pkt = getMessage(null, new DestinationUID(dst), sysid);
if (bad) {
logger.logToAll(logger.INFO, "Packet for message ID=" + sysid + "[" + pkt + "]");
}
} catch (Exception e) {
baddata.put("EXCEPTION-PACKET[" + sysid + "]", dst);
logger.logStack(logger.ERROR, "Failed to retrieve mesage Packet for message ID=" + sysid + " in destination " + dst + ": " + e.getMessage(), e);
}
}
} catch (Exception e) {
data = e.getMessage();
logger.logStack(logger.ERROR, e.getMessage(), e);
}
map.put("[" + tableName + "]SysMessageID:DestinationID(brokerID=" + brokerid + ")\n", data);
if (!baddata.isEmpty()) {
map.put("EXCEPTION!![" + tableName + "]SysMessageID:DestinationID(brokerID=" + brokerid + ")\n", baddata);
}
return map;
}
use of com.sun.messaging.jmq.io.Packet in project openmq by eclipse-ee4j.
the class MessageDAOImpl method getMessage.
/**
* Get a Message.
*
* @param conn database connection
* @param dstUID the destination
* @param id the system message id of the message
* @return Packet the message
*/
@Override
public Packet getMessage(Connection conn, DestinationUID dstUID, String id) throws BrokerException {
Packet msg = null;
boolean myConn = false;
PreparedStatement pstmt = null;
ResultSet rs = null;
Exception myex = null;
try {
// Get a connection
DBManager dbMgr = DBManager.getDBManager();
if (conn == null) {
conn = dbMgr.getConnection(true);
myConn = true;
}
pstmt = dbMgr.createPreparedStatement(conn, selectSQL);
pstmt.setString(1, id);
rs = pstmt.executeQuery();
msg = (Packet) loadData(rs, true);
} catch (Exception e) {
myex = e;
try {
if ((conn != null) && !conn.getAutoCommit()) {
conn.rollback();
}
} catch (SQLException rbe) {
logger.log(Logger.ERROR, BrokerResources.X_DB_ROLLBACK_FAILED + "[" + selectSQL + "]", rbe);
}
Exception ex;
if (e instanceof BrokerException) {
throw (BrokerException) e;
} else if (e instanceof InvalidPacketException) {
InvalidPacketException ipe = (InvalidPacketException) e;
ipe.appendMessage("[" + id + ", " + dstUID + "][" + selectSQL + "]");
ex = ipe;
} else if (e instanceof PacketReadEOFException) {
PacketReadEOFException pre = (PacketReadEOFException) e;
pre.appendMessage("[" + id + ", " + dstUID + "][" + selectSQL + "]");
ex = pre;
} else if (e instanceof IOException) {
ex = DBManager.wrapIOException("[" + selectSQL + "]", (IOException) e);
} else if (e instanceof SQLException) {
ex = DBManager.wrapSQLException("[" + selectSQL + "]", (SQLException) e);
} else {
ex = e;
}
throw new BrokerException(br.getKString(BrokerResources.X_LOAD_MESSAGE_FAILED, id), ex);
} finally {
if (myConn) {
Util.close(rs, pstmt, conn, myex);
} else {
Util.close(rs, pstmt, null, myex);
}
}
if (msg == null) {
throw new BrokerException(br.getKString(BrokerResources.E_MSG_NOT_FOUND_IN_STORE, id, dstUID), Status.NOT_FOUND);
}
return msg;
}
Aggregations