- Log into the management console of WSO2 EI and click Create under Data Service.
- Add a name for the data service and go to the next step.
- Connect to the Company database that you defined above.
- Click Next to go to the Queries screen.
- Click Add New Query to specify the query details:
Enter UpdateAccBalanceEnter updateAccBalanceQ as the query ID.
Enter the following SQL dialect:
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:
The fields in the Add Events screen are explained below.
Event Id: account_balance_low_trigger
The ID used for identifying the event-trigger used in data services queries.
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: product_stock_low_topic
The topic to which the event notifications are published.
Event Sink URL: mailto:firstname.lastname@example.org
A subscription can be any endpoint that is complaint 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.
Save the event.
- Save the UpdateAccBalance query.
Create an operation for the UpdateAccBalance query as shown belowthe updateAccountBalanceQ query.
Save the Operation.
Click Finish to navigate to the Deployed Services window from where you can manage data services.