Skip to content

Toro Cloud Dev Center

Using events to trigger Event Based Workflows

Another purpose of external events is to trigger Event Based Workflows. A Event Based Workflow can be started by an external event if one of its triggers is equal to the external event. Inputs from the external event are passed as part of the execution request which will then be mapped to the Event Based Workflow's inputs. If a validation error occurs, the service won't be started.

When a Event Based Workflow is triggered by an external event, a String input named $triggerFluxEvent will be available to the service. This is used to determine which trigger was used to start the service.

To demonstrate triggering, create a Event Based Workflow that logs a message to System.out and then follow the instructions below:

Adding triggers

Adding a trigger

Adding a trigger

  1. Click any blank part of the canvas to show the Flux Properties view.
  2. For this example, add a trigger named invoked.

    In Martini Desktop, you need to click the Triggers field in the view and then click on the button. If you're in Martini Online, just double click it. A dialog or modal will pop-up and prompt you to enter triggers that you want for your service.

    You can add other triggers, too. Just make sure to separate them by line.

  3. Save your file.

Triggering Event Based Workflows

  1. Open the Console tab to verify if the Event Based Workflow will be executed later.

    To do this in Martini Desktop, right click on your Martini instance and then click on Open Martini Console. In Martini Online, just click on the Console tab at the bottom panel; it's visible by default.

  2. Access the Send Flux Event dialog on the same menu by clicking Flux > Send Flux Event. Alternatively, you can right click on the canvas and select Send Flux Event from there.

  3. Input invoke as the event and click Send. Your service should be executed and you should see some logs on the console:

    Triggering a Event Based Workflow

    Triggering a Event Based Workflow

  4. This time, edit your service and log $triggerFluxEvent instead to see which trigger was used to invoke the service. Send another event when finished and you should see invoke logged on the console.

    Triggering a Event Based Workflow that logs `$triggerFluxEvent`

    Triggering a Event Based Workflow that logs `$triggerFluxEvent`