Skip to content

Instantly share code, notes, and snippets.

@ikus060
Created May 31, 2016 17:46
Show Gist options
  • Save ikus060/e26c3086a42cab11730db03050682dcd to your computer and use it in GitHub Desktop.
Save ikus060/e26c3086a42cab11730db03050682dcd to your computer and use it in GitHub Desktop.
from("timer://actionrequests?period=1&delay=" + period)
// HTTP GET
.to(value + "actionrequests/" + queueName + "/pop?httpClient.soTimeout=5000")
// If empty, wait
.choice()
.when(header(Exchange.HTTP_RESPONSE_CODE).isEqualTo(204))
.log(LoggingLevel.TRACE, "actionrequests route idle")
.delay(period)
.endChoice()
// Else process
.otherwise()
.log(LoggingLevel.TRACE, LOG, "receiving incomming action request ${body}")
.unmarshal(gsonActionRequestFormat)
.log(LoggingLevel.INFO, LOG, "receiving incomming action request [${body.actionid}]")
.process(actionRequestProcessor)
// Finnaly, Delete action
.log(LoggingLevel.INFO, LOG, "sending action request delete [${body.actionid}]")
.setHeader(Exchange.HTTP_METHOD, constant("DELETE"))
.setHeader(Exchange.HTTP_PATH, simple("actionrequests/" + queueName + "/${body.actionid}"))
.setBody(constant(null))
.to(value);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment