Created
January 3, 2014 14:32
-
-
Save bibryam/8238776 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
| 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