Versions Compared

Key

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

You can create an event trigger from a query as explained below. 

...

  1. 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
    borderWidth1
    Localtabgroup
    Localtab
    activetrue
    titleOn MacOS/Linux/CentOS

    Open a terminal and execute the following command:

    Code Block
    sudo wso2ei-6.45.0-integrator
    Localtab
    titleOn Windows
    Go to Start Menu -> Programs -> WSO2 -> Enterprise Integrator 6.45.0 Integrator. This will open a terminal and start the ESB profile.
  2. Open the ESB profile's Management Console using https://localhost:9443/carbon, and log in using admin as the username and the password.

  3. In the Data Service menu click Create.
  4. Enter a name for the data service and click Next.
  5. Connect to the Company database that you defined above.

    Datasource IDDatasource
    Datasource TypeRDBMS
    Datasource Type (Default/External)Leave Default selected.
    Database EngineMySQL
    Driver Classcom.mysql.jdbc.Driver
    URLjdbc:mysql://localhost:3306/Company
    User NameEnter your MySQL server's username. Example: root
    PasswordEnter your MySQL server's password. 
    If you have not assigned a password, keep this field empty. 
  6. Click Next to go to the Queries screen.
  7. 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
    3. Click Generate Input Mapping to automatically generate input mappings for the AccountID and Balance fields.
    4. At the bottom of the page you will find the Events section :

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

      Event IdEnter 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 TopicEnter product_stock_low_topic. The topic to which the event notifications are published.  
      Event Sink URLEnter 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:
       

    6. Click Save and click Main Configuration to go back to the query page.

    7. 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.
    8. Save the UpdateAccBalance query.
  8. Create an operation for the UpdateAccBalance query as shown below.

    Operation NameUpdateAccBalanceOp
    Query IDUpdateBalance

  9. Save the operation.

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

...