Event Notification Nodes

From PresenceWiki
Revision as of 09:18, 20 August 2015 by Rob (Talk | contribs)

(diff) ←Older revision | view current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Event Notification Nodes

These Nodes allow for wait / notify behaviour between separate Tasks, or between separate Threads resulting from a Fork Execution Node.

For example, let's say that Task A splits into two threads using a Fork Execution Node:

Wait event task.png

The first branch queries an inventory database, and then goes on to do make Web Service calls to get currency exchange rates. While this is going on, another branch performs an LDAP query to retrieve the email addresses of managers. We don't want the email to be sent until the inventory query and price lookup is complete, so a Wait Node is placed before the Send Email and a "Send Event Notification" Node is placed after the "Lookup Currency Rates" Node.

So the expected order of execution is as follows:

  • 1) Start of Task
  • 2) Load Inventory
  • 3) Fork Exectution
    • 4) Lookup Currency Rates (in separate thread)
  • 5) LDAP Query
  • 6) Wait On Event
    • 7) Send Event Notification (in separate thread)
  • 8) Send Email
  • 9) End of Task.

Wait On Event

The Wait on Event Node pauses Task Execution until an expected message is received, usually from another Thread or a separate Task.

The expected Message is identified with an Event Identifier. This should be a string of text that is unique to this event. It is good practice to include the Task Name in the identifier to ensure that it does not get confused with another Event from a separate Task.

It is also possible to include Presence variable values or column values for the Event Identifier. If a column value is used, the Node will wait for multiple events before continuing.

Wait for event dialog.png

You can also specify a Timeout value here. If the wait time exceeds the Timeout value an Exception will be raised which can be handled by an Error Handler Node.

Send Event Notification

The Send Event Notification Node raises Event messages that are consumed by "Wait On Event" Nodes, allowing them to continue execution.

Raise event dialog.png

See Also

Task Elements > Flow Control Task Elements > Event Notification Nodes

Schedule Nodes | Decision Point Nodes | Start of Task | End of Task | Error Handler
Throw Exception | Passive Node | Log Entry | Sleep For n Seconds | While Node | Loop Node | Exit Loop Node | |Switch Node
Fork Execution | Join Forked Threads | Start Synch Block | End Synch Block | Event Notification Nodes

Task Elements | Resources