You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@synapse.apache.org by Jens Goldhammer <go...@googlemail.com> on 2008/02/12 20:47:28 UTC

difference between handleException, SynapseException and mediate return false

Hello,

can you explain me the concept behind these things.
IMO, handleException is only a layer over SynapseException, but what 
should I use in the my own mediation?
What happens if I return false in the mediate-method? In my case the 
outSequence will be executed. Does it only mean that further child 
mediations will not be executed?

Thanks,
Jens




Re: difference between handleException, SynapseException and mediate return false

Posted by "Asankha C. Perera" <as...@wso2.com>.
A temporary workaround would be not use a target endpoint for a proxy, 
but to move that endpoint to within a <send> mediator from the inSequence.

asankha

Upul Godage wrote:
> In the current release if a mediator in the inSequence returns false,
> inSequence will stop executing further mediators in the inSequence. But it
> will forward the message to the given target/endpoint  even when the
> inSequence returns false.  That is why the response from the endpoint goes
> through the outSequence.
>
> This has been fixed in the Synapse trunk now. If the inSequence returns
> false, Synapse will not forward the message to target/endpoint now.
>
> Thanks.
>
> Upul
>
>
>
>
> Ok, It will stop further mediation, but does this imply that all
>   
>> following sequences are stopped? I have a case where I return false from
>> my mediate-method(), but the outSequence is also executed.
>> Stacktrace and synapse config is attached...
>> I give back a false in the mediate-method of the
>> roleBasedRouting-mediator, but Synapse tries to send the message to the
>> endpoint. So I can only stop the outSequence by throwing an exception,
>> right?
>> Does the false only influences execution of mediators in the same
>> sequence? The log mediator (mark bold in the config below) after the
>> rolebased mediator will not be executed...
>>
>>     
>
>   

Re: difference between handleException, SynapseException and mediate return false

Posted by Upul Godage <up...@gmail.com>.
In the current release if a mediator in the inSequence returns false,
inSequence will stop executing further mediators in the inSequence. But it
will forward the message to the given target/endpoint  even when the
inSequence returns false.  That is why the response from the endpoint goes
through the outSequence.

This has been fixed in the Synapse trunk now. If the inSequence returns
false, Synapse will not forward the message to target/endpoint now.

Thanks.

Upul




Ok, It will stop further mediation, but does this imply that all
> following sequences are stopped? I have a case where I return false from
> my mediate-method(), but the outSequence is also executed.
> Stacktrace and synapse config is attached...
> I give back a false in the mediate-method of the
> roleBasedRouting-mediator, but Synapse tries to send the message to the
> endpoint. So I can only stop the outSequence by throwing an exception,
> right?
> Does the false only influences execution of mediators in the same
> sequence? The log mediator (mark bold in the config below) after the
> rolebased mediator will not be executed...
>

Re: difference between handleException, SynapseException and mediate return false

Posted by Jens Goldhammer <go...@googlemail.com>.
Ruwan,

comments are inline...

Ruwan Linton schrieb:
> Hi Jens,
>
> Please find y comments inline,
>
> On Feb 13, 2008 1:17 AM, Jens Goldhammer <goldhammerdev@googlemail.com 
> <ma...@googlemail.com>> wrote:
>
>     Hello,
>
>     can you explain me the concept behind these things.
>     IMO, handleException is only a layer over SynapseException, but what
>     should I use in the my own mediation?
>
>
> handleException is a method provided by the AbstractMediator class in 
> order to handle the Exception, for example this method will log the 
> message that you pass to this method and the exception trace and then 
> throws a SynapseException.
Ok, this makes sense. If I am in the init-method of the mediator-class I 
have no access to the messageContext and only can use throw new 
SynapseException...

>  
>
>
>     What happens if I return false in the mediate-method?
>
>
> It will stop further mediation. That is the message will be dropped 
> soon after the execution of the mediator, which returns false.
>  
Ok, It will stop further mediation, but does this imply that all 
following sequences are stopped? I have a case where I return false from 
my mediate-method(), but the outSequence is also executed.
Stacktrace and synapse config is attached...
I give back a false in the mediate-method of the 
roleBasedRouting-mediator, but Synapse tries to send the message to the 
endpoint. So I can only stop the outSequence by throwing an exception, 
right?
Does the false only influences execution of mediators in the same 
sequence? The log mediator (mark bold in the config below) after the 
rolebased mediator will not be executed...

<syn:inSequence onError="myFaultHandler">
                <!-- <syn:header name="wsse:Security" action="remove"
                    
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" 
/>-->
                <syn:roleBasedRouting>
                    <!-- possible values are: http-header, ws-security -->
                    <syn:authentificationType>
                        ws-security
                    </syn:authentificationType>
                    <!-- possible values are: jdbc, ldap, acegi-security-->
                    <syn:realm type="jdbc">
                        <syn:driverurl>
                            jdbc:derby:UserDatabase;create=true
                        </syn:driverurl>
                        <syn:drivername>
                            org.apache.derby.jdbc.EmbeddedDriver
                        </syn:drivername>
                        <syn:username>wso2esb</syn:username>
                        <syn:password>wso2esb</syn:password>
                    </syn:realm>
                </syn:roleBasedRouting>
*                <syn:log level="full"/>*
            </syn:inSequence>
            <syn:outSequence onError="myFaultHandler">
                <syn:send />
            </syn:outSequence>

>     In my case the
>     outSequence will be executed. 
>
>
> I didn't get this.... Can you explain this a bit more.
 
>
>     Does it only mean that further child
>     mediations will not be executed?
>
>
> Yes. 
>
> Thanks,
> Ruwan
>
>
>
>     Thanks,
>     Jens
>
>
>
>
>
>
> -- 
> Ruwan Linton
> http://www.wso2.org - "Oxygenating the Web Services Platform" 

Re: difference between handleException, SynapseException and mediate return false

Posted by Ruwan Linton <ru...@gmail.com>.
Hi Jens,

Please find y comments inline,

On Feb 13, 2008 1:17 AM, Jens Goldhammer <go...@googlemail.com>
wrote:

> Hello,
>
> can you explain me the concept behind these things.
> IMO, handleException is only a layer over SynapseException, but what
> should I use in the my own mediation?


handleException is a method provided by the AbstractMediator class in order
to handle the Exception, for example this method will log the message that
you pass to this method and the exception trace and then throws a
SynapseException.


>
> What happens if I return false in the mediate-method?


It will stop further mediation. That is the message will be dropped soon
after the execution of the mediator, which returns false.


> In my case the
> outSequence will be executed.


I didn't get this.... Can you explain this a bit more.


> Does it only mean that further child
> mediations will not be executed?


Yes.

Thanks,
Ruwan

>
>
> Thanks,
> Jens
>
>
>
>


-- 
Ruwan Linton
http://www.wso2.org - "Oxygenating the Web Services Platform"