String message = "";
long size = 0;
try {
XmlBlasterException xmlBlasterException = msgErrorInfo.getXmlBlasterException();
ErrorCode errorCode = xmlBlasterException.getErrorCode();
message = xmlBlasterException.getMessage();
MsgQueueEntry[] msgQueueEntries = msgErrorInfo.getMsgQueueEntries();
DispatchManager dispatchManager = (this.sessionInfo == null) ? null : this.sessionInfo.getDispatchManager();
I_Queue msgQueue = msgErrorInfo.getQueue(); // is null if entry is not yet in queue
if (log.isLoggable(Level.FINER)) log.finer("Error handling started: " + msgErrorInfo.toString());
if (msgQueueEntries != null && msgQueueEntries.length > 0) {
// 1. Generate dead letters from passed messages
glob.getRequestBroker().deadMessage(msgQueueEntries, msgQueue, message);
if (msgQueue != null) {
// Remove the above published dead message from the queue
try {
if (log.isLoggable(Level.FINE)) log.fine("Removing " + msgQueueEntries.length + " dead messages from queue");
long removed = 0L;
boolean tmp[] = msgQueue.removeRandom(msgQueueEntries);
for (int i=0; i < tmp.length; i++) if (tmp[i]) removed++;
if (removed != msgQueueEntries.length) {
log.warning("Expected to remove " + msgQueueEntries.length + " messages from queue but where only " + removed + ": " + message);
}
}
catch (XmlBlasterException e) {
log.warning("Can't remove " + msgQueueEntries.length + " messages from queue: " + e.getMessage() + ". Original cause was: " + message);
}
}
}
if (xmlBlasterException.isUser()) {
// The update() method from the client has thrown a ErrorCode.USER* error
if (log.isLoggable(Level.FINE)) log.fine("Error handlig for exception " + errorCode.toString() + " done");
return;
}
// 2a. Generate dead letters if there are some entries in the queue
size = (msgQueue == null) ? 0 : msgQueue.getNumOfEntries();