AWS Simple Workflow (SWF)
Since Camel 2.13
Both producer and consumer are supported
The Simple Workflow component supports managing workflows from Amazon’s Simple Workflow service.
Prerequisites
You must have a valid Amazon Web Services developer account, and be signed up to use Amazon Simple Workflow. More information are available at Amazon Simple Workflow.
URI Format
aws-swf://<workflow|activity>[?options]
You can append query options to the URI in the following format, ?options=value&option2=value&…
URI Options
The AWS Simple Workflow (SWF) component supports 30 options, which are listed below.
Name | Description | Default | Type |
---|---|---|---|
amazonSWClient (common) |
To use the given AmazonSimpleWorkflowClient as client |
AmazonSimpleWorkflow |
|
configuration (common) |
The component configuration |
SWFConfiguration |
|
dataConverter (common) |
An instance of com.amazonaws.services.simpleworkflow.flow.DataConverter to use for serializing/deserializing the data. |
DataConverter |
|
domainName (common) |
The workflow domain to use. |
String |
|
eventName (common) |
The workflow or activity event name to use. |
String |
|
region (common) |
Amazon AWS Region. When using this parameter, the configuration will expect the capitalized name of the region (for example AP_EAST_1) You’ll need to use the name Regions.EU_WEST_1.name() |
String |
|
version (common) |
The workflow or activity event version to use. |
String |
|
bridgeErrorHandler (consumer) |
Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. |
false |
boolean |
lazyStartProducer (producer) |
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. |
false |
boolean |
activityList (activity) |
The list name to consume activities from. |
String |
|
activitySchedulingOptions (activity) |
Activity scheduling options |
ActivitySchedulingOptions |
|
activityThreadPoolSize (activity) |
Maximum number of threads in work pool for activity. |
100 |
int |
activityTypeExecutionOptions (activity) |
Activity execution options |
ActivityTypeExecutionOptions |
|
activityTypeRegistration Options (activity) |
Activity registration options |
ActivityTypeRegistrationOptions |
|
basicPropertyBinding (advanced) |
Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities |
false |
boolean |
clientConfigurationParameters (advanced) |
To configure the ClientConfiguration using the key/values from the Map. |
Map |
|
startWorkflowOptionsParameters (advanced) |
To configure the StartWorkflowOptions using the key/values from the Map. |
Map |
|
sWClientParameters (advanced) |
To configure the AmazonSimpleWorkflowClient using the key/values from the Map. |
Map |
|
accessKey (security) |
Amazon AWS Access Key. |
String |
|
secretKey (security) |
Amazon AWS Secret Key. |
String |
|
childPolicy (workflow) |
The policy to use on child workflows when terminating a workflow. |
String |
|
executionStartToCloseTimeout (workflow) |
Set the execution start to close timeout. |
3600 |
String |
operation (workflow) |
Workflow operation. The value can be one of: SIGNAL, CANCEL, TERMINATE, GET_STATE, START, DESCRIBE, GET_HISTORY |
START |
String |
signalName (workflow) |
The name of the signal to send to the workflow. |
String |
|
stateResultType (workflow) |
The type of the result when a workflow state is queried. |
String |
|
taskStartToCloseTimeout (workflow) |
Set the task start to close timeout. |
600 |
String |
terminationDetails (workflow) |
Details for terminating a workflow. |
String |
|
terminationReason (workflow) |
The reason for terminating a workflow. |
String |
|
workflowList (workflow) |
The list name to consume workflows from. |
String |
|
workflowTypeRegistration Options (workflow) |
Workflow registration options |
WorkflowTypeRegistrationOptions |
The AWS Simple Workflow (SWF) endpoint is configured using URI syntax:
aws-swf:type
with the following path and query parameters:
Path Parameters (1 parameters):
Name | Description | Default | Type |
---|---|---|---|
type |
Required Activity or workflow. The value can be one of: activity, workflow |
String |
Query Parameters (32 parameters):
Name | Description | Default | Type |
---|---|---|---|
amazonSWClient (common) |
To use the given AmazonSimpleWorkflowClient as client |
AmazonSimpleWorkflow |
|
dataConverter (common) |
An instance of com.amazonaws.services.simpleworkflow.flow.DataConverter to use for serializing/deserializing the data. |
DataConverter |
|
domainName (common) |
The workflow domain to use. |
String |
|
eventName (common) |
The workflow or activity event name to use. |
String |
|
region (common) |
Amazon AWS Region. When using this parameter, the configuration will expect the capitalized name of the region (for example AP_EAST_1) You’ll need to use the name Regions.EU_WEST_1.name() |
String |
|
version (common) |
The workflow or activity event version to use. |
String |
|
bridgeErrorHandler (consumer) |
Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. |
false |
boolean |
exceptionHandler (consumer) |
To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. |
ExceptionHandler |
|
exchangePattern (consumer) |
Sets the exchange pattern when the consumer creates an exchange. The value can be one of: InOnly, InOut, InOptionalOut |
ExchangePattern |
|
lazyStartProducer (producer) |
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. |
false |
boolean |
activityList (activity) |
The list name to consume activities from. |
String |
|
activitySchedulingOptions (activity) |
Activity scheduling options |
ActivitySchedulingOptions |
|
activityThreadPoolSize (activity) |
Maximum number of threads in work pool for activity. |
100 |
int |
activityTypeExecutionOptions (activity) |
Activity execution options |
ActivityTypeExecutionOptions |
|
activityTypeRegistration Options (activity) |
Activity registration options |
ActivityTypeRegistrationOptions |
|
basicPropertyBinding (advanced) |
Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities |
false |
boolean |
clientConfigurationParameters (advanced) |
To configure the ClientConfiguration using the key/values from the Map. |
Map |
|
startWorkflowOptionsParameters (advanced) |
To configure the StartWorkflowOptions using the key/values from the Map. |
Map |
|
sWClientParameters (advanced) |
To configure the AmazonSimpleWorkflowClient using the key/values from the Map. |
Map |
|
synchronous (advanced) |
Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). |
false |
boolean |
accessKey (security) |
Amazon AWS Access Key. |
String |
|
secretKey (security) |
Amazon AWS Secret Key. |
String |
|
childPolicy (workflow) |
The policy to use on child workflows when terminating a workflow. |
String |
|
executionStartToCloseTimeout (workflow) |
Set the execution start to close timeout. |
3600 |
String |
operation (workflow) |
Workflow operation. The value can be one of: SIGNAL, CANCEL, TERMINATE, GET_STATE, START, DESCRIBE, GET_HISTORY |
START |
String |
signalName (workflow) |
The name of the signal to send to the workflow. |
String |
|
stateResultType (workflow) |
The type of the result when a workflow state is queried. |
String |
|
taskStartToCloseTimeout (workflow) |
Set the task start to close timeout. |
600 |
String |
terminationDetails (workflow) |
Details for terminating a workflow. |
String |
|
terminationReason (workflow) |
The reason for terminating a workflow. |
String |
|
workflowList (workflow) |
The list name to consume workflows from. |
String |
|
workflowTypeRegistration Options (workflow) |
Workflow registration options |
WorkflowTypeRegistrationOptions |
Required SWF component options
You have to provide the amazonSWClient in the Registry or your accessKey and secretKey to access the Amazon SWF.
Usage
Message headers evaluated by the SWF Workflow Producer
A workflow producer allows interacting with a workflow. It can start a new workflow execution, query its state, send signals to a running workflow, or terminate and cancel it.
Header | Type | Description |
---|---|---|
|
|
The operation to perform on the workflow. Supported operations are: |
|
|
A workflow ID to use. |
|
|
A worfklow run ID to use. |
|
|
The type of the result when a workflow state is queried. |
|
|
The workflow or activity event name to use. |
|
|
The workflow or activity event version to use. |
|
|
The reason for terminating a workflow. |
|
|
Details for terminating a workflow. |
|
|
The policy to use on child workflows when terminating a workflow. |
Message headers set by the SWF Workflow Producer
Header | Type | Description |
---|---|---|
|
|
The worfklow ID used or newly generated. |
|
|
The worfklow run ID used or generated. |
Message headers set by the SWF Workflow Consumer
A workflow consumer represents the workflow logic. When it is started, it will start polling workflow decision tasks and process them. In addition to processing decision tasks, a workflow consumer route, will also receive signals (send from a workflow producer) or state queries. The primary purpose of a workflow consumer is to schedule activity tasks for execution using activity producers. Actually activity tasks can be scheduled only from a thread started by a workflow consumer.
Header | Type | Description |
---|---|---|
|
|
Indicates what type is the current event: CamelSWFActionExecute, CamelSWFSignalReceivedAction or CamelSWFGetStateAction. |
|
|
Indicates whether the current decision task is a replay or not. |
|
|
The time of the start event for this decision task. |
Message headers set by the SWF Activity Producer
An activity producer allows scheduling activity tasks. An activity producer can be used only from a thread started by a workflow consumer ie, it can process synchronous exchanges started by a workflow consumer.
Header | Type | Description |
---|---|---|
|
|
The activity name to schedule. |
|
|
The activity version to schedule. |
Message headers set by the SWF Activity Consumer
Header | Type | Description |
---|---|---|
|
|
The task token that is required to report task completion for manually completed tasks. |
Advanced amazonSWClient configuration
If you need more control over the AmazonSimpleWorkflowClient instance configuration you can create your own instance and refer to it from the URI:
The #client
refers to a AmazonSimpleWorkflowClient in the
Registry.
For example if your Camel Application is running behind a firewall:
AWSCredentials awsCredentials = new BasicAWSCredentials("myAccessKey", "mySecretKey");
ClientConfiguration clientConfiguration = new ClientConfiguration();
clientConfiguration.setProxyHost("http://myProxyHost");
clientConfiguration.setProxyPort(8080);
AmazonSimpleWorkflowClient client = new AmazonSimpleWorkflowClient(awsCredentials, clientConfiguration);
registry.bind("client", client);
Automatic detection of AmazonSimpleWorkflow client in registry
The component is capable of detecting the presence of an AmazonSimpleWorkflow bean into the registry. If it’s the only instance of that type it will be used as client and you won’t have to define it as uri parameter. This may be really useful for smarter configuration of the endpoint.
Dependencies
Maven users will need to add the following dependency to their pom.xml.
pom.xml
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-aws-swf</artifactId>
<version>${camel-version}</version>
</dependency>
where ${camel-version}
must be replaced by the actual version of Camel.
Spring Boot Auto-Configuration
When using aws-swf with Spring Boot make sure to use the following Maven dependency to have support for auto configuration:
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-aws-swf-starter</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
The component supports 31 options, which are listed below.
Name | Description | Default | Type |
---|---|---|---|
camel.component.aws-swf.access-key |
Amazon AWS Access Key. |
String |
|
camel.component.aws-swf.activity-list |
The list name to consume activities from. |
String |
|
camel.component.aws-swf.activity-scheduling-options |
Activity scheduling options. The option is a com.amazonaws.services.simpleworkflow.flow.ActivitySchedulingOptions type. |
ActivitySchedulingOptions |
|
camel.component.aws-swf.activity-thread-pool-size |
Maximum number of threads in work pool for activity. |
100 |
Integer |
camel.component.aws-swf.activity-type-execution-options |
Activity execution options. The option is a com.amazonaws.services.simpleworkflow.flow.worker.ActivityTypeExecutionOptions type. |
ActivityTypeExecutionOptions |
|
camel.component.aws-swf.activity-type-registration-options |
Activity registration options. The option is a com.amazonaws.services.simpleworkflow.flow.worker.ActivityTypeRegistrationOptions type. |
ActivityTypeRegistrationOptions |
|
camel.component.aws-swf.amazon-s-w-client |
To use the given AmazonSimpleWorkflowClient as client. The option is a com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow type. |
AmazonSimpleWorkflow |
|
camel.component.aws-swf.autowired-enabled |
Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. |
true |
Boolean |
camel.component.aws-swf.bridge-error-handler |
Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. |
false |
Boolean |
camel.component.aws-swf.child-policy |
The policy to use on child workflows when terminating a workflow. |
String |
|
camel.component.aws-swf.client-configuration-parameters |
To configure the ClientConfiguration using the key/values from the Map. |
Map |
|
camel.component.aws-swf.configuration |
The component configuration. The option is a org.apache.camel.component.aws.swf.SWFConfiguration type. |
SWFConfiguration |
|
camel.component.aws-swf.data-converter |
An instance of com.amazonaws.services.simpleworkflow.flow.DataConverter to use for serializing/deserializing the data. The option is a com.amazonaws.services.simpleworkflow.flow.DataConverter type. |
DataConverter |
|
camel.component.aws-swf.domain-name |
The workflow domain to use. |
String |
|
camel.component.aws-swf.enabled |
Whether to enable auto configuration of the aws-swf component. This is enabled by default. |
Boolean |
|
camel.component.aws-swf.event-name |
The workflow or activity event name to use. |
String |
|
camel.component.aws-swf.execution-start-to-close-timeout |
Set the execution start to close timeout. |
3600 |
String |
camel.component.aws-swf.lazy-start-producer |
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. |
false |
Boolean |
camel.component.aws-swf.operation |
Workflow operation |
START |
String |
camel.component.aws-swf.region |
Amazon AWS Region. When using this parameter, the configuration will expect the capitalized name of the region (for example AP_EAST_1) You’ll need to use the name Regions.EU_WEST_1.name() |
String |
|
camel.component.aws-swf.s-w-client-parameters |
To configure the AmazonSimpleWorkflowClient using the key/values from the Map. |
Map |
|
camel.component.aws-swf.secret-key |
Amazon AWS Secret Key. |
String |
|
camel.component.aws-swf.signal-name |
The name of the signal to send to the workflow. |
String |
|
camel.component.aws-swf.start-workflow-options-parameters |
To configure the StartWorkflowOptions using the key/values from the Map. |
Map |
|
camel.component.aws-swf.state-result-type |
The type of the result when a workflow state is queried. |
String |
|
camel.component.aws-swf.task-start-to-close-timeout |
Set the task start to close timeout. |
600 |
String |
camel.component.aws-swf.termination-details |
Details for terminating a workflow. |
String |
|
camel.component.aws-swf.termination-reason |
The reason for terminating a workflow. |
String |
|
camel.component.aws-swf.version |
The workflow or activity event version to use. |
String |
|
camel.component.aws-swf.workflow-list |
The list name to consume workflows from. |
String |
|
camel.component.aws-swf.workflow-type-registration-options |
Workflow registration options. The option is a com.amazonaws.services.simpleworkflow.flow.WorkflowTypeRegistrationOptions type. |
WorkflowTypeRegistrationOptions |