As of version 44 see the new "Error Management" menu in the "Code Wizard".
Here is and example to automate "disgracefulWebServiceFailure" errors. This error is fabricated. Replace "disgracefulWebServiceFailure" with the error to automate.
First, from the "Schedule Scripts" tab insert a new schedule script. In the example below I selected "Run script when channel starts" but it might make sense to choose a CRON string to run more frequently on a schedule that best suits the need.
//See if there are any errors using the existing code wizard function before we do anything.
//This is a quick test that avoids the searchErrors call if it is not needed.
if (qie.getErrorCount() > 0) {
var searchText = 'error=disgracefulWebServiceFailure';
//NEW: Search for errors that match the searchText
var results = errorManager.searchErrors(searchText);
qie.debug('searchErrors returned ' + results.size() + ' messageQueueIds.');
qie.debug('The messageQueueIds returned: ' + results);
var messagesResolved = 0;
for (var i=0 ; i < results.size() ; i++) {
var messageQueueId = results.get(i);
//NEW: Use oo get the error details. Ignored for now.
var error = errorManager.getErrorDetail(messageQueueId);
qie.debug('error: ' + error);
//NEW: Use to get the messages source model. Used to check the source for "Bad Value"s and update with "Good Value"
var errorSource = errorManager.getSource(messageQueueId);
qie.debug('errorSource: ' + errorSource);
//NEW: Use to get the messages message model. Ignored for now.
var errorMessage = errorManager.getMessage(messageQueueId);
qie.debug('errorMessage: ' + errorMessage);
//if there is no parent then this message has not been previously resubmitted or resolved
if (!errorManager.hasParent(messageQueueId)) {
if (errorSource !== null) {
if (StringUtils.equals(errorSource.getNode('PID-33.1'), 'Bad Value')) {
//modify the source
errorSource.setNode('PID-33.1', 'Good Value');
errorManager.resolveError(messageQueueId, errorSource);
messagesResolved++;
} else {
qie.debug("This message does not contain 'Bad Value'. Skipping");
}
} else {
qie.debug('This message does not contain a valid source. Skipping');
}
} else {
qie.debug('This message queue was previously resolved. Skipping');
}
}
qie.debug('Finished resolving errors');
qie.queueEmail('rabbit@acme.ltunes.com', 'Auto error resolution summary', 'Resolved ' + messagesResolved + ' errors.');
} else {
qie.debug('No errors found. Nothing to resolve.');
}