Uploaded image for project: 'Synapse'
  1. Synapse
  2. SYNAPSE-738

Function-Templates for Synapse Configuration

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • FUTURE
    • 2.1
    • Core
    • None

    Description

      Implementing Function templates in Synapse can be used to reduce lot of complexity as well as eliminate redundancy at synapse configuration. At the moment a large portion of ESB configuration are at the micro level. Because of this users have to individually configure each and every mediator to achieve some high level task. But what we need is a high level abstraction that users can easily use to model such scenarios .
      For example if we consider following scenario ,

      <proxy name="SplitAggregateProxy">
      <target>
      <inSequence>
      <iterate expression="//m0:getQuote/m0:
      request"
      preservePayload="true"
      attachPath="//m0:getQuote"
      xmlns:m0="http://services.samples">
      <target>
      <sequence>
      <send>
      <endpoint>
      <address

      uri="http://localhost:9000/services/SimpleStockQuoteService"/>
      </endpoint>
      </send>
      </sequence>
      </target>
      </iterate>
      </inSequence>
      <outSequence>
      <aggregate>
      <onComplete expression="//m0:getQuoteResponse"
      xmlns:m0="http://services.samples">
      <send/>
      </onComplete>
      </aggregate>
      </outSequence>
      </target>
      </proxy>

      Here what user really wants to look at is three configuration parameters ,

      1. Two XPath expressions
      2. An endpoint address

      we can hide a lot of this complexity by introducing a 'template' configuration that parameterize (like a function does) a known pattern such as this one.Parameterization can be done using xpath expressions..

      Function templates will look like following in synapse config,
      1)
      <template name="[func name]">
      /*parameters for this function template*/
      <parameter name="p1" />*
      /*any sequence*/
      <any sequence>+
      </template>

      -->A Template is an extension of Sequence , hence template body can contain any sequence in general
      --> any mediator/comp inside template body can refer to its parameters just like a normal function does ,by xpath function scope (ie:-func) variable
      ie:- <aggregate>
      <onComplete xmlns:m0="http://services.samples" expression="$func:p2">
      <log level="full" />
      <send/>
      </onComplete>
      </aggregate>
      OR
      <log level="custom">
      <property name="p1-value" expression="$func:p1"/>
      <property name="p2-value" expression="get-property('func','p2')"/>
      </log>

      2)To invoke a template in synapse we can define a Invoke mediator which will be in the following form. Using a invoke mediator ,from within any sequence of Synapse we would be able to execute a template with the passed on values for parameters such as p1,p2,etc.... :
      <invoke target="[target func template]">
      <parameter name="p2" value="

      {any xpath}

      | plain-value"/>*
      </invoke>

      Attachments

        1. synapse_function_templates.patch
          67 kB
          Udayanga Wickramasinghe
        2. synapse_SYNAPSE-738
          67 kB
          Udayanga Wickramasinghe
        3. synapse_SYNAPSE-738_update.patch
          3 kB
          Udayanga Wickramasinghe
        4. synapse_SYNAPSE-738_config_changes.patch
          15 kB
          Udayanga Wickramasinghe
        5. synapse_SYNAPSE-738_config_changes_update.patch
          18 kB
          Udayanga Wickramasinghe
        6. synapse_SYNAPSE-738_call_tempalate.patch
          3 kB
          Udayanga Wickramasinghe
        7. synapse_SYNAPSE-738_sequence_template_init_bug_fix.patch
          1 kB
          Udayanga Wickramasinghe
        8. synapse_SYNAPSE-738_Iterate_mediator_attachXpath.patch
          0.7 kB
          Udayanga Wickramasinghe

        Activity

          People

            hiranya Hiranya Kasub Jayathilaka
            udayangaw@wso2.com Udayanga Wickramasinghe
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: