Logo
  1. Potens.io
  2. Magnus
  3. Advanced & How To

Articles > Workflow Triggers - Pub/Sub Events (beta)

  • Hub Task
  • Workflow Triggers - Cloud Storage Events (beta)
  • Workflow Triggers - Pub/Sub Events (beta)
  • How to use Magnus with AWS
  • Resumable Workflows
  • Diff Tool - Compare Workflow Versions

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:

  1. the request to execute is queued and processed by the Fair Scheduler
  2. the quota for max enqueued requests per user applies
  3. multiple instances of the Workflow is allowed
  4. 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

  1. Trigger must be enabled for the organization.  Please contact your organization admins.
  2. Before creating the Trigger, user must have already granted offline access to Magnus.  Otherwise, saving of the trigger will fail.
  3. The Pub/Sub topic must have already been created in the organization’s Trigger Cloud Project.
  4. 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

  1. Make sure that prerequisites are met.
  2. From Magnus Homepage, click on Triggers to go to the Triggers Browser.

    001.png

  3. Click on the Add Trigger icon on the upper left corner.

    002.png

  4. Specify Trigger properties.

    sh6.png

    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.

  5. Choose Pub/Sub as Trigger type

    001.png

  6. Specify Pub/Sub event properties.

    002.png

    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


  7. Specify the Workflow.

    006.png

    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.

     

  8. Specify parameter overrides to pass to the Workflow during execution. 
    1. Click on the Arguments link.

      007.png

    2. Select a value:

      003a.png

      1. inherit-var: inherit the parameter value from the Workflow
      2. set-value: set a custom value for the parameter
      3. var_data_*: these are built-in parameters that contain information about the Pub/Sub object that triggered the event.  See below for definitions.
      4. var_event_*: these are built-in parameters that contain information about the event.  See below for definitions.

  9. Click Save to save the trigger.  This could take up to a few minutes.

    You will end up with something like below:

    sh8.png

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

010.png

  1. 013.png Take user to Magnus main landing page.
  2. 014.png Add new Trigger.
  3. Refresh icon: Refresh the page to the latest results.
  4. Content Search is disabled and not supported for now
  5. Scope selector: Owned Triggers option only.
  6. 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

011.png

  1. Trigger Type
  2. Trigger Name.
  3. Owner for the trigger.
  4. 015.png View Trigger , read only mode.
  5. 016.pngDelete Trigger.
  6. 017.pngView the history of the Workflow.
  7. The name of the workflow that is going to be executed by the Trigger.
  8. Who created Trigger.
  9. When Trigger was created.
  10. Status of the Trigger:
    1. failed: Trigger creation failed and by hovering over the status more information will be displayed.
    2. deploying: Trigger is being saved and deployed and during that it can’t be deleted (Delete action icon will be disabled).
    3. deleting:  Trigger is being deleted.
    4. ready: Trigger was a successfully created.
  11. Icon indicating GCS Event based Trigger 
  12. 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.

 012.png

 

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.

Potens.io
Launch Magnus | Goliath