Created
November 30, 2011 21:34
-
-
Save johndemic/1410998 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Custom processor | |
* <p/> | |
* {@sample.xml ../../../doc/CircuitBreaker-connector.xml.sample circuitbreaker:filter} | |
* | |
* @param payload The message payload | |
* @return Some string | |
*/ | |
@Processor | |
public Object filter(@Payload Object payload) { | |
if (getFailureCount() < tripThreshold) { | |
return payload; | |
} else if (breakerTrippedOn != null && System.currentTimeMillis() - breakerTrippedOn.getTime() > tripTimeout) { | |
breakerTrippedOn = null; | |
resetFailureCount(); | |
return payload; | |
} else { | |
throw new CircuitOpenException(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment