Overview
Magnus provides Workflow Triggers as a way to initiate a Workflow execution based on some predefined cloud events. When the watched event is fired, the Workflow is triggered to execute via Remote Workflow Execution v2 via queue. That is:
- the request to execute is queued and processed by the Fair Scheduler
- the quota for max enqueued requests per user applies
- multiple instances of the Workflow is allowed
- the Workflow state is not saved after execution
Pub/Sub Events
Note: this is in Public Beta as of now!
When a new message is published to the watched Pub/Sub topic, the Workflow is triggered to execute with information about the message and event.
This Pub/Sub event is for conversational only, meaning it only supports low traffic topic, and each message cannot have more than 1024 character in length.
Prerequisites before creating the Trigger
- Trigger must be enabled for the organization. Please contact your organization admins.
- Before creating the Trigger, user must have already granted offline access to Magnus. Otherwise, saving of the trigger will fail.
- The Pub/Sub topic must have already been created in the organization’s Trigger Cloud Project.
- Trigger owner must have permission to create subscription (pubsub.subscriptions.create) in the organization’s Trigger Cloud Project and attach subscription (pubsub.topics.attachSubscription) to the watched topic.
Add a Workflow Trigger
- Make sure that prerequisites are met.
- From Magnus Homepage, click on Triggers to go to the Triggers Browser.
- Click on the Add Trigger icon on the upper left corner.
- Specify Trigger properties.
A Trigger has the following properties:
Trigger ID
[Required] Unique name of the Trigger
Description
[Optional] Description of the Trigger
Owner
[Required] Account under which the Workflow is run when triggered if the Workflow is not locked to run always as the Workflow owner.
This is case-sensitive.
Lifetime
[Optional] Period during which the Trigger is enabled.
If not specified, the Trigger is always enabled.
Time Zone
Time zone of the Trigger lifetime. For example, if the Trigger lifetime is 6/1/2018 to 6/2/2018 and the time zone is US/Eastern, then the Trigger will be enabled from 6/1/2018 to 6/2/2018 US/Eastern time. The Trigger time zone does not affect Workflow time zone.
- Choose Pub/Sub as Trigger type
-
Specify Pub/Sub event properties.
A Pub/Sub event has the following properties:Description [Optional] Description of the event Project [Required] The project of the topic. Only topics in organization's trigger Cloud Project are supported. Topic [Required] The topic name
Mode [Required] The mode of the Pub/Sub event. Values are:
- Conversational: This is for topic with low traffic and message size less than 1024 characters in length.
- Transactional: Currently not supported
Message Filter Currently not supported - Specify the Workflow.
It has the following properties:
Description
[Optional] Description of the response.
Workflow ID
[Required] The Workflow to trigger. Only owned or delegated Workflows are allowed.
- Specify parameter overrides to pass to the Workflow during execution.
- Click on the Arguments link.
- Select a value:
- inherit-var: inherit the parameter value from the Workflow
- set-value: set a custom value for the parameter
- var_data_*: these are built-in parameters that contain information about the Pub/Sub object that triggered the event. See below for definitions.
- var_event_*: these are built-in parameters that contain information about the event. See below for definitions.
- Click on the Arguments link.
- Click Save to save the trigger. This could take up to a few minutes.
You will end up with something like below:
The Trigger will be enabled few minutes after saving.
Triggers Browser
All Triggers are listed in Triggers Browser. Triggers Browser lists Triggers by Trigger Type, Name, Owner, Workflow to be execute, Created By and Created At
Action Icons are available for each Trigger providing a quick way to view, show Workflow to execute history, and delete.
Trigger information can be filtered.
Toolbar
- Take user to Magnus main landing page.
- Add new Trigger.
- Refresh icon: Refresh the page to the latest results.
- Content Search is disabled and not supported for now
- Scope selector: Owned Triggers option only.
- Filter: filter Triggers based on the input text on client side.
Row example and action buttons
Results can be sorted ascending or descending by clicking the small arrow next to each column title
- Trigger Type
- Trigger Name.
- Owner for the trigger.
- View Trigger , read only mode.
- Delete Trigger.
- View the history of the Workflow.
- The name of the workflow that is going to be executed by the Trigger.
- Who created Trigger.
- When Trigger was created.
- Status of the Trigger:
- failed: Trigger creation failed and by hovering over the status more information will be displayed.
- deploying: Trigger is being saved and deployed and during that it can’t be deleted (Delete action icon will be disabled).
- deleting: Trigger is being deleted.
- ready: Trigger was a successfully created.
- Icon indicating GCS Event based Trigger
- Icon indicating Pub/Sub Event based Trigger
Paging
- The first line will show a summary how many Triggers were fetched, and only 30 Triggers per page will be displayed.
- The second line will show the number of pages and by clicking different numbers it will show the next 30 Triggers and so on.
- Exit button will take user to the Magnus main landing page.
Definitions of Built-in Parameters
Parameter name | Description |
var_data_message | The message text. If the message is more than 1024 in length, it will be truncated. |
var_data_attributes | The message attributes in JSON string format.at. |
var_event_id | A unique ID for the event |
var_event_timestamp | The date/time this event was created in ISO 8601 format |
var_event_type | The type of the event. |
Internals
Workflow Triggers are backed by Google Cloud Functions. When a Workflow Trigger is created, a respective GCF is created in the organization's Google Cloud project. When event invokes the GCF, the GCF in turns makes a call to remotely execute the Workflow. Per the nature of GCF, it is guaranteed to be invoked at least once for each incoming event (https://cloud.google.com/functions/docs/concepts/exec#execution_guarantees). It is recommended to make the target Workflow idempotent so that when an incoming event invokes it multiple times, the desired results will still be achieved.