errorManager.searchErrors¶
Signature: errorManager.searchErrors(searchText, maxResults*)
Returns: List<Long> messageIds - a list of message IDs
Search for errors matching the searchText.
Valid format is:
'[NodePath[!]=][regex:/]Value[/][,error[!]=errorValue][,from=yyyyMMddHHmmssSSS][,to=yyyyMMddHHmmssSSS][,path=executionPath][,matchLevel=numeric value from 0 to 4,matchError=error text]'
Commas are not allowed in values. The matchLevel and matchError must be specified together. matchError should be the last predicate if combined with other predicates. To use a regular expression in the 'Value' predicate precede the value with 'regex:/' and end it with '/'. For example: PID5.1=regex:/(?i).john./
Note
Please refer to the menu 'Help | Qvera Knowledge Base' and search for 'errorManager' for examples on how to manage errors from scheduled scripts.
Note
The format of the searchText is the same as returned by Search Messages and Distinct Errors dialogs.
Note
Plain text in the searchText defaults to the 'error=' predicate which, performs a contains search on the errorDetail.
Note
All errors are returned when searchText is an empty string.
Parameters¶
| Type | Name | Description | Default |
|---|---|---|---|
| String | searchText | the search string containing the text or predicates to search | |
| Integer | maxResults* | (optional) the maximum number of elements to include in the results. A zero or negative value implies no limit. | 0 |
Example¶
// From a Scheduled Script: every hour, see if we can resolve errors automatically
var messagesResolved = 0;
if (qie.getErrorCount() > 0) {
var results = errorManager.searchErrors("error=disgracefulWebServiceFailure");
for (var i = 0; i < results.size(); i++) {
var messageQueueId = results.get(i);
// Skip messages that were previously resubmitted or resolved
if (errorManager.hasParent(messageQueueId)) {
continue;
}
// Get the message source model so we can inspect and fix "Bad Value"s
var errorSource = errorManager.getSource(messageQueueId);
if (errorSource == null) {
continue;
}
if (StringUtils.equals(errorSource.getNode("PID-33.1"), "Bad Value")) {
// Modify the source and resolve the error
errorSource.setNode("PID-33.1", "Good Value");
errorManager.resolveError(messageQueueId, errorSource);
messagesResolved++;
}
}
// Send a summary email after processing
qie.queueEmail(
"rabbit@acme.ltunes.com",
"Auto error resolution summary",
"Resolved " + messagesResolved + " errors."
);
}