The process definition itself needs nothing else then the camel type definition on a service task.
The integration logic is all delegated to the Camel container. By default the Activiti Engine looks for a camelContext bean in the Spring container.
The camelContext bean defines the Camel routes that will be loaded by the Camel container. In the following example the routes are loaded from a specific Java package,
but you can also define routes directly in the Spring configuration itself.
For more documentation about Camel routes you can look on the Camel website. This user guide only shows an example route definition related to the Activiti integration.
When a Camel task is executed a route is searched for that corresponds to the key of process definition and the identifier of that task, like in the short example above "sendCamel".
An example route defined in Java can look like this:
<programlisting>
public class AsyncCamelRoute extends RouteBuilder {
Note the from endpoint definition "activiti:asyncCamelProcess:serviceTaskAsync1" where activiti relates to the Activiti Camel component. asyncCamelProcess refers to the process definition
key of the process definition. And serviceTaskAsync1 relates to the identifier of the Camel task. The process variables can be copied to the body or the properties of the Camel payload.
In this example the variables are copied as message properties. copyVariablesToBody will copy the variables to the body of the Camel message.
In this example you can also see that a Camel message can be sent to a receive task of an Activiti process instance. In this example a bit of additional Camel logic is used to send the Camel message
to the receive task that's defined in the message header destination property. But eventually the message will be sent to the receive1 or receive2 receive tasks.
By default the message body of the Camel message is expected as a Map and all Map entries will be copied to the Activiti execution. When defining the copyVariablesToProperties=true option the message properties are
copied to the Activiti execution.
</para>
<para>
In addition to sending messages from a process instance to Camel and back again you can also start a process instance from a Camel message.
Note that camelProcess is the process definition key of the process definition for which a process instance will be created when a message is read from the direct:start queue.
</para>
<para>
If you want to define multiple Camel context beans and/or want to use a different bean name, this can be overriden on the Camel task definition like this: