Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Eventing support is provided by the WS-Eventing Web services standard. When a data service request or response triggers an event, the subscribers listening to those events receive notifications. The criteria for triggering an event as well as the destination to which the event notifications should be sent are defined per data service query. When a certain event-trigger is activated, emails will be sent to all the respective subscribers.

...

  1. Log into the management console of WSO2 DSS and click Create in the Data Service menu.
  2. Add a name for the data service and go to the next step.
  3. Connect to the Company database that you defined above.
    1. Enter the URL to your MySQL database in the URL field:  jdbc:mysql://localhost:3306/Company

    2. Enter the username and password to connect to your MySQL database. By default the username is root and the password is blank. 

  4. Click Next to go to the Queries screen.
  5. Click Add New Query to specify the query details:
    1. Enter UpdateAccBalance as the query ID.

    2. Enter the following SQL dialect:

      Code Block
      UPDATE ACCOUNT SET Balance=:Balance WHERE AccountID=:AccountID
  6. Click Generate Input Mapping to automatically generate input mappings for the AccountID and Balance fields.

  7. At the bottom of the page you will find the Events section:

  8. Click Manage Events and add a new event as shown below:
     

    The fields in the Add Events screen are explained below.

    1. Event Idaccount_balance_low_trigger

      Info

      The ID used for identifying the event-trigger used in data services queries.

    2. Xpath/UpdateAccountBalance/Balance<200

      Info

      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. 

    3. Target Topicproduct_stock_low_topic

      Info

      The topic to which the event notifications are published. 

    4. Event Sink URLmailto:youremail@wso2.com 

      Info

      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.

  9. Save the event.

  10. Save the UpdateAccBalance query.
  11. Create an operation for the UpdateAccBalance query as shown below.

  12. Save the Operation.

  13. Click Finish to navigate to the Deployed Services window from where you can manage data services.

...