Skip to main content

How to use Dynamic Registry Keys with WSO2 ESB Mediators

From this post I will going to briefly introduce about one of the new features provided by WSO2 ESB. Earlier WSO2 ESB supported static registry keys where users can select a key for the mediator as a static value. But from ESB 4.0.0 users can use dynamic registry keys where users can define XPath expression to evaluate the registry key in run time.

For an example let's consider XSLT mediator. With earlier static registry key based method user have to define only single XSLT file for transformation. With the use of dynamic registry key, user will be able to use XPath expressions to dynamically generate the registry key, based on the message context. So with that user can have multiple XSLT files and based on the evaluated key mediator will be able to select the required XSLT file in run time.

Following is a sample usage of static and dynamic registry keys and user can use both of them according to situation.
 
  1. Static Registry Key – define the exact path to find the xslt file like bellow.<xslt key="xslt-key-req"/>
Image1 : User can select static key from registry browser

          eg:
    1: <sequence xmlns="http://ws.apache.org/ns/synapse" name="main">
    
    2:     <in>
    
    3:         <xslt key="conf:/repository/synapse/samples/transform/transform.xslt" />
    
    4:     </in>
    
    5:     <out>
    
    6:         <xslt key="conf:/repository/synapse/samples/transform/transform_back.xslt" />
    
    7:     </out>
    
    8:     <send />
    
    9: </sequence>
    

    1. Dynamic Registry Key – Using an Xpath expression inside curly braces {  }, to identify the key like bellow.
    Image2: User can add dynamic key inside { }. Also user can define NameSpaces as well.
          eg:
    1: <xslt xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd" key="{get-property('symbol')}" />
    
    2: 
    
    3: <sequence xmlns="http://ws.apache.org/ns/synapse" name="main">
    
    4:    <in>
    
    5:       <property name="symbol" value="conf:/repository/synapse/samples/transform/transform.xslt" />
    
    6:       <xslt xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd" key="{get-property('symbol')}" />
    
    7:    </in>
    
    8:    <out>
    
    9:       <xslt key="conf:/repository/synapse/samples/transform/transform_back.xslt" />
    
    10:    </out>
    
    11:    <send />
    
    12: </sequence>
    

    Comments

    1. Hi,
      I tried using dynamic registry keys for the following mediator:
      send - works
      xslt - works
      validate - just the main schema works,
      additional external schema doesn't

      a more detailed description can be found here: http://wso2.org/forum/thread/13151

      ReplyDelete
    2. Hi Frank,

      Dynamic key feature is now enabled with Validate, XSLT,Sequence, Send, XQuery and Script Mediators.

      But When considering about Validate mediator you can use dynamic key feature with Schema key.

      But AFAIK, you cant use Dynamic key feature with external resources because it is not supported at the moment.

      Thank You.

      ReplyDelete
    3. Hi Ranga Siriwardena,
      I have one Query in wso2 Data Service Server:-


      Multiple tables depend on each other with Primary key and foregin key, i used the auto generated key in wso2DSS.

      i am inserted data in 1st table and getting auto genreted identity column, using that identity column again i am inserting in 2nd table as well in 3rd also

      @my issue is while inserting in 2nd table error occure due to pk voilation i need to rollback the 1st table row which is already inserted in table how could i do this ...

      ReplyDelete
    4. This comment has been removed by the author.

      ReplyDelete
    5. This comment has been removed by the author.

      ReplyDelete

    Post a Comment

    Popular posts from this blog

    How to install IBM WebSphere MQ on Ubuntu (Linux)

    Following are the steps to install IBM WebSphere MQ version 8 on Ubuntu 14.04. 1) Create a user account with name "mqm" in Ubuntu. This should basically create a user called "mqm" and usergroup called "mqm" 2) Login to "mqm" user account and proceed with next steps 3) Increase the open file limit for the user "mqm" to "10240" or higher value. For this open "/etc/security/limits.conf" file and set the values as bellow. mqm       hard  nofile     10240 mqm       soft   nofile     10240 4) Increase the number of processes allowed for the user "mqm" to "4096" or higher value. For this open "/etc/security/limits.conf" file and set the values as bellow. You will need to edit this file as a sudo user. mqm       hard  nproc      4096 mqm       soft   nproc      4096 5) Install "RPM" on Ubuntu if you already don't have it. sudo apt-get install rpm   6) Download

    Creating a Simple Axis Service(.aar file) and Deploy it in WSO2 Application Server

    In this post I am explaining how to Create a Simple Axis Service(.aar file) and Deploy it in WSO2 Application Server using a simple sample. And also at the end I am describing how to do the same thing with creation of a Jar Service. Lets assume "sample-home" as our parent directory and inside that we can create following folder structure. With this folder structure we can include our external libraries (jar files) inside lib folder and  the "services.xml" file inside "META-INF" folder. Following is the sample services.xml definition which I used with this sample creation. < service name = "HelloService" > < Description > This is a sample service to explain simple aar service </ Description > < messageReceivers > < messageReceiver mep = "http://www.w3.org/2006/01/wsdl/in-out" class = "org.apache.axis2.rpc.receivers.RPCMessageReceiver" /> </ messageReceivers > < parame