Skip to content

Instantly share code, notes, and snippets.

@johndemic
Created November 30, 2011 21:25
Show Gist options
  • Save johndemic/1410937 to your computer and use it in GitHub Desktop.
Save johndemic/1410937 to your computer and use it in GitHub Desktop.
/**
* Custom processor
* <p/>
* {@sample.xml ../../../doc/CircuitBreaker-connector.xml.sample circuitbreaker:trip}
*
* @param exceptionMessage The exception.
* @param tripOnException The exception type we should trip on.
* @return Some string
*/
@Processor
public Object trip(String tripOnException, @Payload ExceptionMessage exceptionMessage) {
if (exceptionMessage.getException().getCause().getClass().getCanonicalName().equals(tripOnException)) {
incrementFailureCount();
if (getFailureCount() == tripThreshold) {
breakerTrippedOn = new Date();
}
}
return exceptionMessage;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment