Skip to content

Instantly share code, notes, and snippets.

@bibryam
Created August 20, 2014 22:54
Show Gist options
  • Select an option

  • Save bibryam/032cab33e42ecdfb401d to your computer and use it in GitHub Desktop.

Select an option

Save bibryam/032cab33e42ecdfb401d to your computer and use it in GitHub Desktop.
Clustered Idempotent Camel Route
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