You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by Rajith Attapattu <ra...@gmail.com> on 2007/04/22 17:04:42 UTC

Can we do this type of logic with existing syanpse mediators?

Hi folks,

Can we achieve the following functionality (or simillar) using the current
mediators?

<conditional>
   <if><script language="js">.........<script>
      <send><endpoint address="" /></send>
  </if>
   <if><script language="js">.........<script>
      <send><endpoint address="" /></send>
  </if>
  <else>
    <send><endpoint address="" /></send>
  </else>
</conditional>

If not, is there a value in having something like this? Here is my use case.


<transaction>
  <cardType>visa<cardType>
  <cardNumber>12343466<cardNumber>
  <amount>154.45<amount>
  <date>.......<date>
<transaction>

The logic is.

if (amount > 300)
{
   send to fraudScreeningService
}
else if (time > 21.00 or time < 8.00)
{
   send to fraudScreeningService
}
else
{
   send to my service.
}

Regards,

Rajith

Re: Can we do this type of logic with existing syanpse mediators?

Posted by Rajith Attapattu <ra...@gmail.com>.
Asankha,

Thanks a lot for your prompt reply.
sure, I can file a jira for it.

The reason why I like if we can also do a small script evaluation for the
condition (filter) is so that we can use  logic other than regex or xpath
expressions.
For example a script can pick up the system date easily.

Here is a rough example.

<if>
        <script language="js">.<![CDATA[
                var d=new Date();
                var time=d.getHours();
                if (time > 20 )
                {
                   return true ;
                }
         ]]><script>
      <send><endpoint address="" /></send>
 </if>
  <else>
    <send><endpoint address="" /></send>
  </else>

regards,

Rajith

On 4/22/07, Asankha C. Perera <as...@wso2.com> wrote:
>
> Rajith
>
> The answer to your question is yes, we can do this right now. However we
> do not have a 'else if' or 'else' as the conditional mediator is a
> 'filter' that is able to evaluate a boolean Xpath expression over the
> current message, or evaluate the result of an Xpath over the current
> message against a regex match. But the inclusion of an 'else' and 'else
> if' should not be a difficult task. I was also looking into the
> possibility to read the system time as the Xpath 1.0 which we support
> does not support it natively. Again this is a minor enhancement. Would
> you be interested in filing an enhancement request for either of these?
>
> asankha
>
> Rajith Attapattu wrote:
> > Hi folks,
> >
> > Can we achieve the following functionality (or simillar) using the
> > current mediators?
> >
> > <conditional>
> >    <if><script language="js">.........<script>
> >       <send><endpoint address="" /></send>
> >   </if>
> >    <if><script language="js">.........<script>
> >       <send><endpoint address="" /></send>
> >   </if>
> >   <else>
> >     <send><endpoint address="" /></send>
> >   </else>
> > </conditional>
> >
> > If not, is there a value in having something like this? Here is my use
> > case.
> >
> > <transaction>
> >   <cardType>visa<cardType>
> >   <cardNumber>12343466<cardNumber>
> >   <amount>154.45<amount>
> >   <date>.......<date>
> > <transaction>
> >
> > The logic is.
> >
> > if (amount > 300)
> > {
> >    send to fraudScreeningService
> > }
> > else if (time > 21.00 or time < 8.00)
> > {
> >    send to fraudScreeningService
> > }
> > else
> > {
> >    send to my service.
> > }
> >
> > Regards,
> >
> > Rajith
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: synapse-dev-help@ws.apache.org
>
>

Re: Can we do this type of logic with existing syanpse mediators?

Posted by "Asankha C. Perera" <as...@wso2.com>.
Rajith

The answer to your question is yes, we can do this right now. However we 
do not have a 'else if' or 'else' as the conditional mediator is a 
'filter' that is able to evaluate a boolean Xpath expression over the 
current message, or evaluate the result of an Xpath over the current 
message against a regex match. But the inclusion of an 'else' and 'else 
if' should not be a difficult task. I was also looking into the 
possibility to read the system time as the Xpath 1.0 which we support 
does not support it natively. Again this is a minor enhancement. Would 
you be interested in filing an enhancement request for either of these?

asankha

Rajith Attapattu wrote:
> Hi folks,
>
> Can we achieve the following functionality (or simillar) using the 
> current mediators?
>
> <conditional>
>    <if><script language="js">.........<script>
>       <send><endpoint address="" /></send>
>   </if>
>    <if><script language="js">.........<script>
>       <send><endpoint address="" /></send>
>   </if>
>   <else>
>     <send><endpoint address="" /></send>
>   </else>
> </conditional>
>
> If not, is there a value in having something like this? Here is my use 
> case.
>
> <transaction>
>   <cardType>visa<cardType>
>   <cardNumber>12343466<cardNumber>
>   <amount>154.45<amount>
>   <date>.......<date>
> <transaction>
>
> The logic is.
>
> if (amount > 300)
> {
>    send to fraudScreeningService
> }
> else if (time > 21.00 or time < 8.00)
> {
>    send to fraudScreeningService
> }
> else
> {
>    send to my service.
> }
>
> Regards,
>
> Rajith

---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org