Start Signal Event with REST example
Using Alfresco Process Services powered by Activiti, this example will demonstrate how to throw a signal in the global scope of the tenant for other processes to catch.
I am going to show one example of how to use a signal to start a process, but there a several ways to use the signal event.
You may choose to send a REST signal instead of using the REST call when there are several processes you wish to start at the same time or you don't know the ID of the process you want to start.
Configuring the REST call
- Define the REST header authentication in the under "Basic Auths" in the Identity Management > Tenants > Endpoints section
- Define the REST endpoint under "Endpoints" in the Identity Management > Tenants > Endpoints section. For the Protocol, Host, and Port sections, enter the relevant information for your activiti-app configuration.
- In your process, add a REST call task activity.
- Configure the REST call task:
- Request mapping:
The JSON of the request mapping should be similar to:
"value":"This is a string"
The values are:
signalName - The name of the signal you are throwing and catching. You will need to define this in the process that you want to catch the signal.
tenantId - The ID of the tenant in which to throw the signal. In a non-MT environment, the tenantId will be "tenant_1"
async - If you want the throw to be executed asynchronously
variables - Any variables you want to pass to catch events. You will need to define these in the catch process.
6. Request header:
Header name: Content-Type
Header value: application/json
HTTP method: POST
Base endpoint: http://<aps_host>:<aps_port>
Rest URL: /activiti-app/api/runtime/signals?tenantId=<your_tenant_id>
REST configuration is complete
Configuring the Start Signal Event
- In the editor for the process that will catch the signal, open up the signal definition and add a new signal:
- The signal name, defined under the "Signal Definitions", needs to match what you defined in the REST call, or vice versa:
- The scope needs to be global
- Next, add a Start Signal Event to the process
- Under the configuration for the event, select your defined signal from the drop down under Signal Reference
- If you are passing variables with the signal, as defined in your REST call, define those variables in the global space of the process
- Build out the rest of your process
You can find sample apps and process on my Github
The example files may not work with the community edition of Activiti, but the concepts are the same.