com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

Eventing Sample

Eventing is used to send notifications when a particular action is completed, such as when an operation with particular arguments is invoked or when a specific response is returned. Notifications are enabled in WSO2 DSS using input and output event triggers.

About the sample data service

The EventingSample data service used here is based on the functionality of managing the inventory of a car/motorcycle dealership. It contains the following queries:

  • addProduct: A new product is added to the catalog using the addProductQuery query.
  • updateProductQuantity: The availability of a certain product is updated using the updateProductQuantityQuery query. This is linked with an input event trigger, which monitors whether the stock of this product is critically low. If so, if fires an event notifying the subscribers that this product's stock needs to be updated.
  • getProductByCode: When the product code is given, the getProductByCodeQuery query retrieves product information. The company gives special attention to people querying the database for motocycles. So when a query is made where the product type is "motorcycle", an output trigger associated with this query sends messages to the respective subscribers, which is our email address in this sample. 

Prerequisites

In this sample, we have defined a specific topic for events to be published, and an email address is added as a subscription for that topic. In order to allow mails to be sent, we have to configure the mail sender in the client Axis2 configuration. Open the <DSS_HOME>/repository/conf/axis2/axis2_client.xml file and add the following mail sender configuration.

<transportSender name="mailto"
 class="org.apache.axis2.transport.mail.MailTransportSender">
 <parameter name="mail.smtp.from">esb.sample@gmail.com</parameter>
 <parameter name="mail.smtp.user">esb.sample</parameter>
 <parameter name="mail.smtp.password">esb*sample8</parameter>
 <parameter name="mail.smtp.host">smtp.gmail.com</parameter>
 <parameter name="mail.smtp.port">587</parameter>
 <parameter name="mail.smtp.starttls.enable">true</parameter>
 <parameter name="mail.smtp.auth">true</parameter>
 </transportSender>

Building the sample

Follow the steps given below.

  1. The sample data service (EventingSample) should be deployed using the instructions in the Samples Setup section.
  2. Log in to the management console of your product and edit the data service by adding a valid email address: 
    1. Click List in the Services menu, and select the EventingSample service. 
    2. Use the XML Edit option to edit the dataservice. In the XML view, replace all occurrences of "test@test.com" with your own email address.

Running the Sample

The sample service can be run using the TryIt tool, which is bundled with the WSO2 Data Services Server, or a code-generated java client sample as discussed in the Data Services Clients section.

Follow the steps below to demonstrate this functionality using the TryIt tool:

  1. Log in to the management console of your server and click List under Services in the navigator. The EventingSample will be listed here.
  2. Click Try this service to open the TryIt tool.
  3. Select the relevant operation and click Send to execute the command as shown below.
    • We will first add a new product into the inventory by executing the "addProduct" operation:

    •  After adding the product, we will update the availability of it by changing the product quantity in stock. Execute the "updateProductQuantity" operation:

      Here we are setting the "quantityInStock" to 5. Because of the event trigger, when the stock is less than 10, an event is fired. Soon you will receive an event notification to your mail inbox. Figure below shows the contents of the email attachment.

    • Here we are querying the inventory system for a specific motorcycle model by executing the "getProductByCode" operation.

      By making a request with the motorcycle product line, we are triggering an event associated with it. An email will be sent regarding this query. The contents of the email is as follows:
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.