Bonita
Since Camel 2.19
Only producer is supported
Used for communicating with a remote Bonita BPM process engine.
URI format
bonita://[operation]?[options]
Where operation is the specific action to perform on Bonita.
Configuring Options
Camel components are configured on two separate levels:
-
component level
-
endpoint level
Configuring Component Options
At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.
For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.
Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.
You can configure components using:
-
the Component DSL.
-
in a configuration file (
application.properties,*.yamlfiles, etc). -
directly in the Java code.
Configuring Endpoint Options
You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.
Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.
A good practice when configuring options is to use Property Placeholders.
Property placeholders provide a few benefits:
-
They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.
-
They allow externalizing the configuration from the code.
-
They help the code to become more flexible and reusable.
The following two sections list all the options, firstly for the component followed by the endpoint.
Component Options
The Bonita component supports the following options which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
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 | |
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 | |
Enable usage of global SSL context parameters, for the endpoints with the https protocol that have no sslContextParameters of their own. | false | boolean |
Endpoint Options
The Bonita endpoint is configured using URI syntax:
bonita:operation
With the following path and query parameters:
Query Parameters
| Name | Description | Default | Type |
|---|---|---|---|
The context path of the Bonita web application on the server, such as /bonita or the path that a reverse proxy maps to it. The producer calls the REST API, the login and the file uploads under it. A missing leading slash is added and a trailing slash removed, and / is the root of the server. | /bonita | String | |
The host name of the Bonita server. The producer calls the REST API under the context path of the basePath option on this host. | localhost | String | |
The HTTP port of the Bonita server. | 8080 | String | |
Required The exact name of the process to start a case of. When the process is deployed in several versions, processVersion selects one. The producer fails when it starts if the option is not set, and fails the exchange if no process has this name. | String | ||
The version of the process to start a case of. If not set and the process is deployed in several versions, the producer uses the first one that Bonita returns and logs a WARN that names it. | String | ||
The protocol of the REST API of the Bonita server: http, or https to send the login, the session cookies and the requests over TLS. With https, set the port to the HTTPS port of the server, and the sslContextParameters option when the JVM does not trust the certificate of the server. Enum values:
| http | String | |
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 | |
Required The password of the Bonita account. The producer logs in with it at the loginservice of Bonita before each request, and fails when it starts if the option is not set. | String | ||
The SSL configuration of the HTTPS connections to the Bonita server, such as the trust store with the certificate of the server. It is used only when the protocol is https; without it the default SSL context of the JVM is used. | SSLContextParameters | ||
Required The username of the Bonita account. The producer logs in with it at the loginservice of Bonita before each request, and fails when it starts if the option is not set. | String |
Message Headers
The Bonita component supports the following message header(s), which is/are listed below:
| Name | Description | Default | Type |
|---|---|---|---|
| Constant: | The id of the case that the startCase operation started. | String |
Message Body
The message body at each side of the Bonita component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.
| Side | Body | Description |
|---|---|---|
Producer input |
| The contract inputs of the process: a Map of the input names and their Serializable values, a FileInput for a file to upload, or a JSON object as text that is parsed into that Map with Jackson. Any other body, also JSON text that is not an object, fails with an InvalidPayloadException. |
Producer output |
| The body as sent: a Map of the inputs has each FileInput replaced by a Map of its filename and the tempPath of the upload. The id of the case started is in the CamelBonitaCaseId header. |
The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.
Usage
Body content
For the startCase operation, the input variables are retrieved from the body message. This one has to contain a Map<String,Serializable>, or a JSON object as text (String, byte[] or InputStream) such as {"amount": 1}, which is parsed into that Map. Any other body, also JSON text that is not an object (such as a JSON array), fails with an InvalidPayloadException.
After the operation, the body is still the Map of the inputs, or the JSON text that was sent. The id of the started case is set in the CamelBonitaCaseId header.
Using HTTPS
By default, the producer calls the REST API of Bonita over plain HTTP. The username and password of the login, the session cookies and the X-Bonita-API-Token header travel in clear text. Set the protocol option to https to send them over TLS, and set port to the HTTPS port of the Bonita server.
When the JVM does not trust the certificate of the Bonita server, configure a trust store with the sslContextParameters option (or with the global SSL context parameters of Camel and the useGlobalSslContextParameters option of the component). The login and all the requests of the producer use this SSL context. Without it, the JAX-RS runtime uses the default SSL context of the JVM. The http protocol ignores it.
from("direct:start")
.to("bonita:startCase?protocol=https&hostname=bonita.example.com&port=8443&processName=TestProcess"
+ "&username=install&password=install&sslContextParameters=#bonitaSsl"); Examples
The following example starts a new case in Bonita:
-
Java
-
XML
-
YAML
from("direct:start").to("bonita:startCase?hostname=localhost&port=8080&processName=TestProcess&username=install&password=install"); <route>
<from uri="direct:start"/>
<to uri="bonita:startCase?hostname=localhost&port=8080&processName=TestProcess&username=install&password=install"/>
</route> - route:
from:
uri: direct:start
steps:
- to:
uri: bonita:startCase
parameters:
hostname: localhost
port: 8080
processName: TestProcess
username: install
password: install Dependencies
To use Bonita in your Camel routes, you need to add a dependency on camel-bonita, which implements the component.
If you use Maven, you can add the following to your pom.xml, substituting the version number for the latest and greatest release (see the download page for the latest versions).
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-bonita</artifactId>
<version>x.x.x</version>
</dependency>