Using Events to Trigger Flux Services
Another purpose of external events is to trigger Flux Services. A Flux Service 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 Flux service's inputs. If a validation error occurs, the service won't be started.
When a Flux Service 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 Flux Service that logs a message to
System.out and then follow
the instructions below:
- Click any blank part of the canvas to show the Flux Properties view.
For this example, add a trigger named
In Coder Studio, simply click the Triggers property in the view and then click on the ... button. If you're in Coder Cloud, 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.
Save your file.
Triggering Flux Services
Open the TORO Integrate Console to verify if the Flux Service will be executed later.
To do this in Coder Studio, right click on your TORO Integrate instance and then click on Open Integrate Console. In Coder Cloud, the same actions apply but you have to right click at an empty spot in the Coder Navigator view.
Access the Send Flux Event dialog on the same menu by clicking Flux > Send Flux Event.
invokeas the event and click Send. Your service should be executed and you should see some logs on the console:
This time, edit your service and log
$triggerFluxEventinstead to see which trigger was used to invoke the service. Send another event when finished and you should see
invokelogged on the console.