You can create an event trigger from a query as explained below.
...
Start or restart the ESB profile of WSO2 Enterprise Integrator.
Info You need to restart the ESB profile for the changes you made to the
axis2_client.xml
file to reflect in the server.Panel borderColor #542989 bgColor #ffffff borderWidth 1 Localtabgroup Localtab active true title On MacOS/Linux/CentOS Open a terminal and execute the following command:
Code Block wso2ei-6.6.0-integrator
Localtab title On Windows Go to Start Menu -> Programs -> WSO2 -> Enterprise Integrator 6.6.0 Integrator. This will open a terminal and start the ESB profile. Open the ESB profile's Management Console using
https://localhost:9443/carbon
, and log in usingadmin
as the username and the password.- In the Data Service menu click Create.
- Enter a name for the data service and click Next.
Connect to the Company database that you defined above.
Datasource ID Datasource Datasource Type RDBMS Datasource Type (Default/External) Leave Default selected. Database Engine MySQL Driver Class com.mysql.jdbc.Driver
URL jdbc:mysql://localhost:3306/Company
User Name Enter your MySQL server's username. Example: root Password Enter your MySQL server's password.
If you have not assigned a password, keep this field empty.- Click Next to go to the Queries screen.
- Click Add New Query to specify the query details:
Enter UpdateAccBalance as the query ID.
Enter the following SQL dialect:
Code Block UPDATE ACCOUNT SET Balance=:Balance WHERE AccountID=:AccountID
- Click Generate Input Mapping to automatically generate input mappings for the AccountID and Balance fields.
At the bottom of the page you will find the Events section :
Click Manage Events and add a new event as shown below:
Event Id Enter account_balance_low_trigger
.
This is the ID used for identifying the event-trigger used in data services queries.Xpath Enter
/UpdateAccBalance/Balance<200
.Represents an XPath expression that is run against the XML message presented. That is the request/response message. When this evaluation returns
true
, the event is triggered.Target Topic Enter product_stock_low_topic
. The topic to which the event notifications are published.Event Sink URL Enter the email to which the event notifications need to be sent in the following format: mailto:<YOUR_EMAIL>
A subscription can be any endpoint that is compliant with WS-Eventing. For example, you can use an SMTP transport to send a message to a mail inbox, where an email address is given as the subscription. Here, many subscriptions can be defined for the given topic.Example:
Click Save and click Main Configuration to go back to the query page.
- You can now add the event as an event trigger for the query as shown below.
Since the event sends notifications related to the data input, you need to add the event as an Input Event Trigger. - Save the UpdateAccBalance query.
Create an operation for the UpdateAccBalance query as shown below.
Operation Name UpdateAccBalanceOp
Query ID UpdateBalance
Save the operation.
Click Finish to navigate to the Deployed Services window from where you can manage data services.
...