Skip to content

Instantly share code, notes, and snippets.

@bibryam
Created January 3, 2014 14:32
Show Gist options
  • Select an option

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

Select an option

Save bibryam/8238776 to your computer and use it in GitHub Desktop.
package com.ofbizian.swf.demo;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.aws.swf.SWFConstants;
import org.apache.camel.main.Main;
public class WorkflowConsumer {
public static void main(String[] args) throws Exception {
Main main = new Main();
main.enableHangupSupport();
WorkflowConsumerRoute route = new WorkflowConsumerRoute();
main.addRouteBuilder(route);
main.run();
}
static class WorkflowConsumerRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("aws-swf://workflow?" + WorkflowProducer.COMMON_OPTIONS + "&eventName=calculator")
.choice()
.when(header(SWFConstants.ACTION).isEqualTo(SWFConstants.SIGNAL_RECEIVED_ACTION))
.log("Signal received ${body}")
.when(header(SWFConstants.ACTION).isEqualTo(SWFConstants.GET_STATE_ACTION))
.log("State asked ${body}")
.when(header(SWFConstants.ACTION).isEqualTo(SWFConstants.EXECUTE_ACTION))
.setBody(simple("${body[0]}"))
.log("EXECUTION TASK RECEIVED ${body}")
.filter(simple("${body} > 5"))
.to("aws-swf://activity?" + WorkflowProducer.COMMON_OPTIONS + "&eventName=incrementor");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment