setTriggerExpression method

void setTriggerExpression(
  1. String? trigger
)

Sets the boolean expression that will be evaluated against each update and will act as a trigger to deliver the push notification.

If a trigger expression is set, the MPN subscription does not send any push notifications until the expression evaluates to true. When this happens, the MPN subscription "triggers" and a single push notification is sent. Once triggered, no other push notifications are sent. In other words, with a trigger expression set, the MPN subscription sends at most one push notification.
The expression must be in Java syntax and can contain named arguments with the format ${field}, or indexed arguments with the format $[1]. The same rules that apply to setNotificationFormat apply also to the trigger expression. The expression is verified and evaluated on the server.
Named and indexed arguments are replaced by the server with the value of corresponding subscription fields before the expression is evaluated. They are represented as String variables, and as such appropriate type conversion must be considered. E.g.

  • Double.parseDouble(${last_price}) > 500.0
Argument variables are named with the prefix LS_MPN_field followed by an index. Thus, variable names like LS_MPN_field1 should be considered reserved and their use avoided in the expression.
Consider potential impact on server performance when writing trigger expressions. Since Java code may use classes and methods of the JDK, a badly written trigger may cause CPU hogging or memory exhaustion. For this reason, a server-side filter may be applied to refuse poorly written (or even maliciously crafted) trigger expressions. See the "General Concepts" document for more information.
Note: if the MpnSubscription has been created by the client, such as when obtained through [LightstreamerClient.getMpnSubscriptions], named arguments are always mapped to its corresponding indexed argument, even if originally the trigger expression used a named argument.
Note: the content of this property may be subject to length restrictions (See the "General Concepts" document for more information).

Lifecycle This property can be changed at any time.

Notification A change to this setting will be notified through a call to MpnSubscriptionListener.onPropertyChanged with argument trigger on any MpnSubscriptionListener listening to the related MpnSubscription.

  • trigger the boolean expression that acts as a trigger to deliver the push notification. If the value is null, no trigger is set on the subscription.

  • See isTriggered

Implementation

external void setTriggerExpression(String? trigger);