You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by Udayanga Wickramasinghe <ud...@wso2.com> on 2011/03/08 16:07:13 UTC

Function-Templates for Synapse Configuration

Hi Devs,
We thought of implementing $subject for Synapse. 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 believe 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..

implementation of function templates will look like following in synapse
config,
1) we have Function Template in the form ;

<template name="[func name]">
    <params>
               <parameter name="p1" />*
    </params>
     <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>


--> we have to define template at top level so that it is a reusable
function that can be referred by others
-->A func template can execute other functions or execute recursively (using
Invoke mediator)

2)To invoke a template in synapse we have to use a Invoke mediator which
will be defined in the following  form. Using a invoke mediator ,from
within any sequence we would be able to invoke 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>


IMO this will greatly reduce complexity of the configurations and would be
able to eliminate redundancy...WDYT?.. really appreciate feedback regarding
this
Regards,,
Udayanga


-- 
*Udayanga Wickramasinghe*
Software Engineer; WSO2 Inc.; http://wso2.com,
*email: **udayanga@wso2.com* <ud...@wso2.com>* cell: +94 (77) 983-4365
blog: **http://udayangawiki.blogspot.com*<http://udayangawiki.blogspot.com/>
*
twitter: **http://twitter.com/udayanga_wick*<http://twitter.com/udayanga_wick>
*
*

Re: Function-Templates for Synapse Configuration

Posted by Udayanga Wickramasinghe <ud...@wso2.com>.
Hi ,

On Wed, Mar 9, 2011 at 11:06 AM, indika kumara <in...@gmail.com>wrote:

> Udayanga, lets go with what you have already done. As we discussed
> off-line, we can give the same experience for users for defining both
> endpoint and sequence templates. We can improve things at later.
>
thanks a lot for your insights :) ..sure will do..i believe we would be able
to unify both at a later point

Regards,
Udayanga


>
> Thanks,
>
> Indika
>
>
> On Wed, Mar 9, 2011 at 11:02 AM, Udayanga Wickramasinghe <
> udayanga@wso2.com> wrote:
>
>> Hi Indika,
>>
>> On Tue, Mar 8, 2011 at 11:03 PM, indika kumara <in...@gmail.com>wrote:
>>
>>> Udayanga, +1 for the approach.
>>>
>>> However, I have several concerns
>>>
>>> Could this and the endpoint template proposed by Supun be similar?
>>> Personally, I believe it would be better to reduce language constructs
>>> defined by the language. As the synapse language supposed to be a DSL, I
>>> think making it simple, domain specific, and intutive would be important.
>>>
>>> it has similar intent..but implementations might be different...IMO what
>> supun has suggested is a static configuration for endpoints without any
>> parametrization.
>>
>>
>>
>>> Supun used 'endpoint-template' and in your configuration it is 'template'
>>> (is this a sequence-template?).
>>>
>>> yes it is more on the lines of a sequence-template
>>
>>
>>> We may be able to use 'template' for Both or at least the same way of
>>> doing - conceptual integrity.
>>>
>>
>> true. But since they contain some amount of orthogonality , I think best
>> option is  to implement these different cases first and see the possibility
>> of connecting them later :)
>>
>> Regards,
>> Udayanga--
>>
>> *Udayanga Wickramasinghe*
>> Software Engineer; WSO2 Inc.; http://wso2.com,
>> *email: **udayanga@wso2.com* <ud...@wso2.com>* cell: +94 (77)
>> 983-4365
>> blog: **http://udayangawiki.blogspot.com*<http://udayangawiki.blogspot.com/>
>> *
>> twitter: **http://twitter.com/udayanga_wick*<http://twitter.com/udayanga_wick>
>> *
>> *
>>
>
>


-- 
*Udayanga Wickramasinghe*
Software Engineer; WSO2 Inc.; http://wso2.com,
*email: **udayanga@wso2.com* <ud...@wso2.com>* cell: +94 (77) 983-4365
blog: **http://udayangawiki.blogspot.com*<http://udayangawiki.blogspot.com/>
*
twitter: **http://twitter.com/udayanga_wick*<http://twitter.com/udayanga_wick>
*
*

Re: Function-Templates for Synapse Configuration

Posted by indika kumara <in...@gmail.com>.
Udayanga, lets go with what you have already done. As we discussed off-line,
we can give the same experience for users for defining both endpoint and
sequence templates. We can improve things at later.

Thanks,

Indika

On Wed, Mar 9, 2011 at 11:02 AM, Udayanga Wickramasinghe
<ud...@wso2.com>wrote:

> Hi Indika,
>
> On Tue, Mar 8, 2011 at 11:03 PM, indika kumara <in...@gmail.com>wrote:
>
>> Udayanga, +1 for the approach.
>>
>> However, I have several concerns
>>
>> Could this and the endpoint template proposed by Supun be similar?
>> Personally, I believe it would be better to reduce language constructs
>> defined by the language. As the synapse language supposed to be a DSL, I
>> think making it simple, domain specific, and intutive would be important.
>>
>> it has similar intent..but implementations might be different...IMO what
> supun has suggested is a static configuration for endpoints without any
> parametrization.
>
>
>
>> Supun used 'endpoint-template' and in your configuration it is 'template'
>> (is this a sequence-template?).
>>
>> yes it is more on the lines of a sequence-template
>
>
>> We may be able to use 'template' for Both or at least the same way of
>> doing - conceptual integrity.
>>
>
> true. But since they contain some amount of orthogonality , I think best
> option is  to implement these different cases first and see the possibility
> of connecting them later :)
>
> Regards,
> Udayanga--
>
> *Udayanga Wickramasinghe*
> Software Engineer; WSO2 Inc.; http://wso2.com,
> *email: **udayanga@wso2.com* <ud...@wso2.com>* cell: +94 (77) 983-4365
> blog: **http://udayangawiki.blogspot.com*<http://udayangawiki.blogspot.com/>
> *
> twitter: **http://twitter.com/udayanga_wick*<http://twitter.com/udayanga_wick>
> *
> *
>

Re: Function-Templates for Synapse Configuration

Posted by Udayanga Wickramasinghe <ud...@wso2.com>.
Hi Indika,

On Tue, Mar 8, 2011 at 11:03 PM, indika kumara <in...@gmail.com>wrote:

> Udayanga, +1 for the approach.
>
> However, I have several concerns
>
> Could this and the endpoint template proposed by Supun be similar?
> Personally, I believe it would be better to reduce language constructs
> defined by the language. As the synapse language supposed to be a DSL, I
> think making it simple, domain specific, and intutive would be important.
>
> it has similar intent..but implementations might be different...IMO what
supun has suggested is a static configuration for endpoints without any
parametrization.



> Supun used 'endpoint-template' and in your configuration it is 'template'
> (is this a sequence-template?).
>
> yes it is more on the lines of a sequence-template


> We may be able to use 'template' for Both or at least the same way of doing
> - conceptual integrity.
>

true. But since they contain some amount of orthogonality , I think best
option is  to implement these different cases first and see the possibility
of connecting them later :)

Regards,
Udayanga--

*Udayanga Wickramasinghe*
Software Engineer; WSO2 Inc.; http://wso2.com,
*email: **udayanga@wso2.com* <ud...@wso2.com>* cell: +94 (77) 983-4365
blog: **http://udayangawiki.blogspot.com*<http://udayangawiki.blogspot.com/>
*
twitter: **http://twitter.com/udayanga_wick*<http://twitter.com/udayanga_wick>
*
*

Re: Function-Templates for Synapse Configuration

Posted by indika kumara <in...@gmail.com>.
Udayanga, +1 for the approach.

However, I have several concerns

Could this and the endpoint template proposed by Supun be similar?
Personally, I believe it would be better to reduce language constructs
defined by the language. As the synapse language supposed to be a DSL, I
think making it simple, domain specific, and intutive would be important.

Supun used 'endpoint-template' and in your configuration it is 'template'
(is this a sequence-template?).

We may be able to use 'template' for Both or at least the same way of doing
- conceptual integrity.

Defining a template  ( analogous to a Class)

 <template name="[func name]">
     <parameter name="p1" />*
     <any synapse construct> {i.e endpoint, sequence, proxy, task}
 </template>

Calling a template (analogous to Creating an instance of a Class)

Creating a sequence from a template

<sequence name="" template-ref="">
   <parameter name="p2"  value="{any xpath} | plain-value"/>*
<sequence>

Creating an endpoint

<endpoint name="" template-ref="">
   <parameter name="p2"  value="{any xpath} | plain-value"/>*
<endpoint>
 .....................
 ....................

It may be accepatble to use 'endpoint-template', 'sequence-template',
'proxy-template', etc ...but I believe we should do that in the same way
(i.e using parameter tags and template-ref )- conceptual integrity.

Thanks,

Indika

On Tue, Mar 8, 2011 at 9:07 PM, Udayanga Wickramasinghe
<ud...@wso2.com>wrote:

> Hi Devs,
> We thought of implementing $subject for Synapse. 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 believe 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..
>
> implementation of function templates will look like following in synapse
> config,
> 1) we have Function Template in the form ;
>
> <template name="[func name]">
>     <params>
>                <parameter name="p1" />*
>     </params>
>      <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>
>
>
> --> we have to define template at top level so that it is a reusable
> function that can be referred by others
> -->A func template can execute other functions or execute recursively
> (using Invoke mediator)
>
> 2)To invoke a template in synapse we have to use a Invoke mediator which
> will be defined in the following  form. Using a invoke mediator ,from
> within any sequence we would be able to invoke 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>
>
>
> IMO this will greatly reduce complexity of the configurations and would be
> able to eliminate redundancy...WDYT?.. really appreciate feedback regarding
> this
> Regards,,
> Udayanga
>
>
> --
> *Udayanga Wickramasinghe*
> Software Engineer; WSO2 Inc.; http://wso2.com,
> *email: **udayanga@wso2.com* <ud...@wso2.com>* cell: +94 (77) 983-4365
> blog: **http://udayangawiki.blogspot.com*<http://udayangawiki.blogspot.com/>
> *
> twitter: **http://twitter.com/udayanga_wick*<http://twitter.com/udayanga_wick>
> *
> *
>