cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

ThingWorx Events Explained

100% helpful (1/1)

Business logic and actions in a ThingWorx application are driven by events.  Events are interesting or critical property states that a Thing publishes to subscribers.  Events are defined at the thing, thing template, or thing shape level, and can be as simple as a new data value from a device, to complex events from many data points.  An event that is created on a thing shape or thing template level is inherited down into the entities that implement the shape or template that defines the event.

 

Types of Events

  • Built-in
  • Custom

 

Built-in Events

Every entity in ThingWorx can use several built-in events.  These events are automatically triggered when a prerequisite condition is met.  In some cases, you must provide information that determines the specifics of that prerequisite.

 

Common built-in events include:

  • Data Change
  • Alert
  • Timer

 In ThingWorx, there are standard events and related data packets (defined by Data Shapes).  The most common type of event is a Data Change related to a Thing property.  The Data Change fires when a property value changes. The specifics of this event can be configured from the Data Change Info section of the Property Creation page.  When you define a property, there are many configuration aspects.

 

Example:

 

Using DataChangeEvent, you have a few options for setting an event to fire when there is new data for a property:

  • only if the data has changed
  • only if the data evaluates true or false
  • only if the new value changed beyond a defined threshold

 

The Alert event is also attached to a property and is set up from the Property Definition page.  An Alert event fires when the value of the property reaches a certain threshold or value.  Depending on the base type, you may specify the condition of this event from the Manage Alerts button.

 

Timer events can be used to run jobs or fire events on a regular basis.  Things themselves can fire specific events such as Thing Start or “special” things, like a Timer type thing that contains special event(s).

 

How to Set up and Configure Timers

 

Creating a Custom Event

To create a new custom event:

 

  1. In ThingWorx Composer, open up the Thing, Thing Template, or Thing Shape for edit where the new Event will be added
  2. From the sidebar menu under Entity Information, select Events
  3. Click Add My Event
  4. Provide the event with a name and a data shape that describes the data being sent to a subscriber
  5. Click Done and Save

 image

Once created, the event appears on the Subscriptions page for subscribing.  Since the event is custom built, you must specify when it triggers.  This is often accomplished from within a service.

 

Best Practices

  • There should be a subscriber to the event in the model. The subscriber is sent a data packet and the subscription is initiated. If no one is subscribed to the event (no one is listening), nothing happens.
  • DataChange events hit the event processing subsystem (see Event Processing Subsystem below), which has fewer threads allocated to it than some other subsystems:
    • If queries within subscriptions to data change events take too long, this will cause a back-up in the event processing subsystem
    • Too much activity in this subsystem may result in poor system performance, and even server crashes
    • Be cautious what types of calculations are performed in data change event subscriptions

      Refer to the following knowledge base article regarding tricky data change event use cases, the implementation of rules for alerts, and conditional operations:  Complicated Event Calculations in ThingWorx
  • Load Test all applications in Sandbox before committing changes to Production to ensure mashups can handle all design choices on large scales

 

Event Processing Subsystem

The Event Processing Subsystem manages event processing for external subscriptions (Things subscribing to other Things) throughout ThingWorx.

 

Event Queue Processing Settings

Base Type

Default

Notes

Min Threads Allocated to Event Processing Pool

NUMBER

16

 

Max Threads Allocated to Event Processing Pool

NUMBER

500

 

Max Queue Entries Before Adding New Working Thread

NUMBER

200000

Maximum number of entries to queue before adding a thread to the pool

 

 

Additional Information

PTC ThingWorx Help Center - Thing Events

Event Types

Creating and Triggering Custom Events in ThingWorx

 

Comments

(scheduler)scheduled event in thingworx 9.3, given example. 

Version history
Last update:
‎Mar 12, 2018 01:37 PM
Updated by:
Labels (1)