Created
August 20, 2014 22:54
-
-
Save bibryam/032cab33e42ecdfb401d to your computer and use it in GitHub Desktop.
Clustered Idempotent Camel Route
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
| public class IdempotentRoute extends RouteBuilder { | |
| private static final transient Logger LOGGER = LoggerFactory.getLogger(IdempotentRoute.class); | |
| private InfinispanIdempotentRepository infinispanRepo; | |
| private int port; | |
| @Override | |
| public void configure() throws Exception { | |
| from("restlet:http://localhost:" + port + "/idempotent/{key}?restletMethods=GET") | |
| .idempotentConsumer(header("key"), infinispanRepo) | |
| .setBody(simple("UNIQUE REQUEST ACCEPTED: ${header.key}")) | |
| .stop() | |
| .end() | |
| .setBody(simple("REQUEST REJECTED: ${header.key}")); | |
| } | |
| public InfinispanIdempotentRepository getInfinispanRepo() { | |
| return infinispanRepo; | |
| } | |
| public void setInfinispanRepo(InfinispanIdempotentRepository infinispanRepo) { | |
| this.infinispanRepo = infinispanRepo; | |
| } | |
| public void start() { | |
| port = AvailablePortFinder.getNextAvailable(8080); | |
| LOGGER.info("Using port: " + port); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment