Apama 10.7.2 | Using Apama with Software AG Designer | Using Query Designer | Creating queries in Query Designer | Adding query actions | Adding query send event actions
 
Adding query send event actions
In the Query Designer Actions pane, add the send event action(s) you want Apama to perform when it finds a match for the event pattern specified in the query. You can specify one or more send actions as well as one or more custom actions.
Before you define query actions, you should add the query input events and specify the query pattern. If this query uses parameters, you should add the query parameters before you add actions. You can then refer to the parameters in the actions.
*To add a send action to a query
1. In the Actions pane of the Query Designer, click the drop down arrow to the right of the plus sign and select Send Event to create a send event action. The New Query Send Event Action dialog appears.
2. Click Choose, and select the Event type.
Note:
The Event Type Selection dialog displays the automatically generated query output event definition from other queries in the project. You can select the automatically generated query output event definition as an input to the query. For more information, see Using the output of another query as query input.
3. In the Name field, enter a name for the send event action.
4. In the Description field, optionally enter a description of what the action performs.
5. In the Channel field, specify an EPL expression to which the event will be sent. The EPL expression must evaluate to a string. If you are using a string literal, you have to enclose the string literal within quotes.
For example, in the sample Delayed_InOrder_Events_Car_Sample, you can use an EPL expression caralert.carId in the Channel field for the event type apamax.querysamples.delayedcarevents.CarEngineAlert. Here, "caralert." is a channel name prefix which is combined with the carId value. If the value of carId is 10, then the channel to which the event will be sent is caralert.10.
*To insert an event field or an expression, right-click the Channel field and select the required event field or expression.
*To convert an expression to a plain text:
1. Select the expression that you want to convert to plain text
2. Right-click the selected expression
3. Select switch to plain text [ctrl-p]
*To convert plain text to an expression:
1. Select the plain text that you want to convert to an expression
2. Right-click the selected plain text
3. Select switch to expression [ctrl-e]
6. In the Fields table, specify a value to every field name.
To specify a value to a field name, select the field name and click the edit sign . The Edit dialog appears.
In the Edit dialog:
*To insert an expression, right-click in the text box and select the required expression. Click OK.
*To convert an expression to a plain text:
1. Select the expression that you want to convert to plain text
2. Right-click the selected expression
3. Select switch to plain text [ctrl-p]
4. Click OK
*To convert plain text to an expression:
1. Select the plain text that you want to convert to an expression
2. Right-click the selected plain text
3. Select switch to expression [ctrl-e]
4. Click OK
The Fields table displays event fields and the values to be specified for the event. Values can be any valid EPL expression. Only string literals need to be enclosed within quotes. If any fields that are not present in the event definition have been incorrectly added to the Send Event action's event in the Source editor tab, then these fields are listed in the missing fields table. These missing fields and values are persisted with the Send Event action when you click OK. If you do not want these missing fields and values to persist, click Clear List. Clear List removes all the missing fields and values from the Send Event action.
7. If you have used an or operator in the query pattern, you can select the events to be matched in the Require these events to be matched by the pattern section. Events that are on one side of an or operator in the pattern are optional as they may not be matched by the pattern if the alternative events are matched instead. The Require these events to be matched by the pattern section sets which events must be matched by the pattern in order for the send event action to send the event. If the value from an optional event is used in the send event action, then it must be selected in the Require the events to be matched by the pattern. It is not legal to use the optional events without setting them as required. It is also possible to add optional terms to the Require these events to be matched by the pattern section manually, if sending the event should be conditional on the events being matched.
If the names of the coassignments in the pattern are modified or removed, then the send event action may refer to old names. Click Clear missing events to remove the missing coassignments.
8. Click OK when the send action definition is complete.
If you look at the Source view of the query, you can see that for each action you define, Query Designer inserts a %send statement in the EPL query definition. The %send() statements appear in the find statement block and can be interleaved with regular EPL.
In the Source view, the modifications you can make to %send statements are to modify the quoted name, the quoted description, and the channel. Any changes you make in the Source view will appear in Query Designer. If there is a syntax error in the Source view, you cannot display the Design view until you correct the error. The recommendation is that only Query Designer should insert %send() statements. At runtime when the query finds a match, it executes all specified actions in the order in which they are listed in the Actions pane, provided any Required events set by the send event action have been matched by the pattern.
To edit a send event action, select the send event action and click the edit sign .
To delete a send event action, select the send event action and click the delete sign .
The arrows at the top of the Actions pane let you change this order. To change the order, select the action you want to move and then click the appropriate arrow as many times as needed.