exception-type-filter with chaining-router

View: New views
7 Messages — Rating Filter:   Alert me  

exception-type-filter with chaining-router

by deepan s :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

We are trying to implement an exception handling strategy for services within a chaining router as explained below,

We have,
A. Mule "GetCustomerDetails" service with an outbound router that chains,
A.1. "GetSourceSystem" service [throws SoruceNotFound exception],
A.2. "GetCustDetailsFromSuperSource" service [called if SourceNotFound exception is thrown by A.1]
A.3. "GetCustDetailsFromFoundSource" service [called if SourceNofFound exception is not thrown by A.1]

B. Another mule "GetAssetDetails" service with an outbound router that chains,
B.1. "GetSourceSystem" service [throws SoruceNotFound exception],
B.2. "GetAssetDetailsFromSuperSource" service [called if SourceNotFound exception is thrown by B.1]
B.3. "GetCustDetailsFromFoundSource" service [called if SourceNofFound exception is not thrown by B.1]

Note that "GetSourceSystem" service appears in the chaining routers of both service A(GetCustomerDetails) & B(GetAssetDetails).

Hence we might have to handle the SourceNotFound exception thrown by "GetSourceSystem" service within the respective chaining routers & NOT within the "GetSourceSystem" service itself.

We tried using exception-type-filter within the chaining-router for "GetCustDetailsFromSuperSource" and "GetAssetDetailsFromSuperSource" to control the flow in case of SourceNotFound exception (as described in http://www.mulesource.org/display/MULE2USER/Error+Handling#ErrorHandling-UsingtheExceptionTypeFilter).

Something like the below,
<service name="GetCustomerDetails">
    <inbound>
         <vm:inbound-endpoint address="vm://getCustomerDetails" synchronous="true" />
     </inbound>
     <outbound>
         <chaining-router>
          <vm:outbound-endpoint address="vm://segmentationService" synchronous="true"/>
<!--vm://getCustDetailsFromSuperSource service should be called when SourceNotFoundException IS thrown by vm://segmentationService-->
          <vm:outbound-endpoint address="vm://getCustDetailsFromSuperSource" synchronous="true">
                 <exception-type-filter expectedType="com.xyz.SourceNotFoundException"/>
          </vm:outbound-endpoint>
<!--vm://getCustDetailsFromFoundSource service should be called when SourceNotFoundException IS NOT thrown by vm://segmentationService. Also Not sure how to skip the below call when SourceNotFoundException IS thrown-->
          <vm:outbound-endpoint address="vm://getCustDetailsFromFoundSource" synchronous="true"/>
        </chaining-router>
     </outbound>
  </service>

But the SourceNotFound exception thrown by the "GetSourceSystem" service is not getting handled in the next service "GetCustDetailsFromSuperSource".

Are we doing something wrong here? Can you please advice?

Regards,
Deepan Subramani.

Re: exception-type-filter with chaining-router

by antoine.borg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

The chaining router does not catch exceptions that are thrown so this is
the wrong router.  Perhaps using the Exception based router will help
though. I talk about this pattern on my blog:  http://ricston.com/blog/?p=22

A

deepan s wrote:

> Hi,
>
> We are trying to implement an exception handling strategy for services
> within a chaining router as explained below,
>
> We have,
> A. Mule "GetCustomerDetails" service with an outbound router that chains,
> A.1. "GetSourceSystem" service [throws SoruceNotFound exception],
> A.2. "GetCustDetailsFromSuperSource" service [called if SourceNotFound
> exception is thrown by A.1]
> A.3. "GetCustDetailsFromFoundSource" service [called if SourceNofFound
> exception is not thrown by A.1]
>
> B. Another mule "GetAssetDetails" service with an outbound router that
> chains,
> B.1. "GetSourceSystem" service [throws SoruceNotFound exception],
> B.2. "GetAssetDetailsFromSuperSource" service [called if SourceNotFound
> exception is thrown by B.1]
> B.3. "GetCustDetailsFromFoundSource" service [called if SourceNofFound
> exception is not thrown by B.1]
>
> Note that "GetSourceSystem" service appears in the chaining routers of both
> service A(GetCustomerDetails) & B(GetAssetDetails).
>
> Hence we might have to handle the SourceNotFound exception thrown by
> "GetSourceSystem" service within the respective chaining routers & NOT
> within the "GetSourceSystem" service itself.
>
> We tried using exception-type-filter within the chaining-router for
> "GetCustDetailsFromSuperSource" and "GetAssetDetailsFromSuperSource" to
> control the flow in case of SourceNotFound exception (as described in
> http://www.mulesource.org/display/MULE2USER/Error+Handling#ErrorHandling-UsingtheExceptionTypeFilter).
>
> Something like the below,
> <service name="GetCustomerDetails">
>     <inbound>
>          <vm:inbound-endpoint address="vm://getCustomerDetails"
> synchronous="true" />
>      </inbound>
>      <outbound>
>          <chaining-router>
>  <vm:outbound-endpoint address="vm://segmentationService"
> synchronous="true"/>
> <!--vm://getCustDetailsFromSuperSource service should be called when
> SourceNotFoundException IS thrown by vm://segmentationService-->
>  <vm:outbound-endpoint address="vm://getCustDetailsFromSuperSource"
> synchronous="true">
>         <exception-type-filter
> expectedType="com.xyz.SourceNotFoundException"/>
>  </vm:outbound-endpoint>
> <!--vm://getCustDetailsFromFoundSource service should be called when
> SourceNotFoundException IS NOT thrown by vm://segmentationService. Also Not
> sure how to skip the below call when SourceNotFoundException IS thrown-->
>  <vm:outbound-endpoint address="vm://getCustDetailsFromFoundSource"
> synchronous="true"/>
>         </chaining-router>
>      </outbound>
>   </service>
>
> But the SourceNotFound exception thrown by the "GetSourceSystem" service is
> not getting handled in the next service "GetCustDetailsFromSuperSource".
>
> Are we doing something wrong here? Can you please advice?
>
> Regards,
> Deepan Subramani.
>
>  

--

Antoine Borg, Senior Consultant | Tel: +32 28 504 696
ricston Ltd., BP 2, 1180 Uccle, Brussels, BELGIUM

See our full schedule of Mule and Android courses:
http://www.ricston.com/courses/schedules/

email: _antoine.borg_@... <mailto:antoine.borg@...> |
blog: blog.ricston.com <http://blog.ricston.com> | web: ricston.com
<http://www.ricston.com/>



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: exception-type-filter with chaining-router

by deepan s :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Appreciate your quick response.

Thanks Antoine, what you suggested worked.

We have one more query,

Is there a condition based routing mechanism?
Say, i have 3 services (taking same input parameter) to be routed in order. And the routing should break and return to the caller when some condition gets satisfied (condition should be evaluated on the response of the service being called)

We can achieve the same using exception based routing by throwing an exception with-in each of the service when the condition is not satisfied (so that the routing proceeds to the next service), but is there a more elegant way of doing this without throwing an exception?

Regards,
Deepan Subramani.


Regards,
Deepan Subramani

antoine.borg wrote:
Hello,

The chaining router does not catch exceptions that are thrown so this is
the wrong router.  Perhaps using the Exception based router will help
though. I talk about this pattern on my blog:  http://ricston.com/blog/?p=22

A

deepan s wrote:
> Hi,
>
> We are trying to implement an exception handling strategy for services
> within a chaining router as explained below,
>
> We have,
> A. Mule "GetCustomerDetails" service with an outbound router that chains,
> A.1. "GetSourceSystem" service [throws SoruceNotFound exception],
> A.2. "GetCustDetailsFromSuperSource" service [called if SourceNotFound
> exception is thrown by A.1]
> A.3. "GetCustDetailsFromFoundSource" service [called if SourceNofFound
> exception is not thrown by A.1]
>
> B. Another mule "GetAssetDetails" service with an outbound router that
> chains,
> B.1. "GetSourceSystem" service [throws SoruceNotFound exception],
> B.2. "GetAssetDetailsFromSuperSource" service [called if SourceNotFound
> exception is thrown by B.1]
> B.3. "GetCustDetailsFromFoundSource" service [called if SourceNofFound
> exception is not thrown by B.1]
>
> Note that "GetSourceSystem" service appears in the chaining routers of both
> service A(GetCustomerDetails) & B(GetAssetDetails).
>
> Hence we might have to handle the SourceNotFound exception thrown by
> "GetSourceSystem" service within the respective chaining routers & NOT
> within the "GetSourceSystem" service itself.
>
> We tried using exception-type-filter within the chaining-router for
> "GetCustDetailsFromSuperSource" and "GetAssetDetailsFromSuperSource" to
> control the flow in case of SourceNotFound exception (as described in
> http://www.mulesource.org/display/MULE2USER/Error+Handling#ErrorHandling-UsingtheExceptionTypeFilter).
>
> Something like the below,
> <service name="GetCustomerDetails">
>     <inbound>
>          <vm:inbound-endpoint address="vm://getCustomerDetails"
> synchronous="true" />
>      </inbound>
>      <outbound>
>          <chaining-router>
>  <vm:outbound-endpoint address="vm://segmentationService"
> synchronous="true"/>
> <!--vm://getCustDetailsFromSuperSource service should be called when
> SourceNotFoundException IS thrown by vm://segmentationService-->
>  <vm:outbound-endpoint address="vm://getCustDetailsFromSuperSource"
> synchronous="true">
>         <exception-type-filter
> expectedType="com.xyz.SourceNotFoundException"/>
>  </vm:outbound-endpoint>
> <!--vm://getCustDetailsFromFoundSource service should be called when
> SourceNotFoundException IS NOT thrown by vm://segmentationService. Also Not
> sure how to skip the below call when SourceNotFoundException IS thrown-->
>  <vm:outbound-endpoint address="vm://getCustDetailsFromFoundSource"
> synchronous="true"/>
>         </chaining-router>
>      </outbound>
>   </service>
>
> But the SourceNotFound exception thrown by the "GetSourceSystem" service is
> not getting handled in the next service "GetCustDetailsFromSuperSource".
>
> Are we doing something wrong here? Can you please advice?
>
> Regards,
> Deepan Subramani.
>
>  

--

Antoine Borg, Senior Consultant | Tel: +32 28 504 696
ricston Ltd., BP 2, 1180 Uccle, Brussels, BELGIUM

See our full schedule of Mule and Android courses:
http://www.ricston.com/courses/schedules/

email: _antoine.borg_@ricston.com <mailto:antoine.borg@ricston.com> |
blog: blog.ricston.com <http://blog.ricston.com> | web: ricston.com
<http://www.ricston.com/>



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Parent Message unknown Re: exception-type-filter with chaining-router

by Andrew Perepelytsya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Consider ComponentBindings. Then your service could orchestrate complex flows.

HTH,
Andrew

On Jul 1, 2009 7:07 AM, "deepan s" <deepans@...> wrote:


Appreciate your quick response.

Thanks Antoine, what you suggested worked.

We have one more query,

Is there a condition based routing mechanism?
Say, i have 3 services (taking same input parameter) to be routed in order.
And the routing should break and return to the caller when some condition
gets satisfied (condition should be evaluated on the response of the service
being called)

We can achieve the same using exception based routing by throwing an
exception with-in each of the service when the condition is not satisfied
(so that the routing proceeds to the next service), but is there a more
elegant way of doing this without throwing an exception?

Regards,
Deepan Subramani.


Regards,
Deepan Subramani

antoine.borg wrote: > > Hello, > > The chaining router does not catch exceptions that are thrown...

--
View this message in context: http://www.nabble.com/exception-type-filter-with-chaining-router-tp24267008p24287951.html
Sent from the Mule - User mailing list archive at Nabble.com.

--------------------------------------------------------------------- To unsubscribe from this lis...


Re: exception-type-filter with chaining-router

by deepan s :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andrew,

To use component binding for my scenario, i might have to bind more than one endpoints (implementing same interface) to my component, so that i can make some routing decisions with in the component class implementation.

I can find the below quoted from the mule document, but not sure how
"With component bindings it is possible to configure multiple interfaces or a single interface with a an endpoint bound to one or more Mule endpoints. "

Can you please advice on how my Invoker component class should look like, can i do some thing like this...

public class InvokerComponent {
private HelloInterface[] hello; // i have an array of components bound
public String invoke(String s) {  // i make routing decisions
     String result = hello[0].sayHello(s, "English");
     if(result.equals("xyz")){
           result = hello[1].sayHello(s, "English");
     }
     return result;
}
public void setHello(HelloInterface[] hello) {
    this.hello = hello;
}
public HelloInterface[] getHello() {
     return hello;
}
}

Thanks,
Deepan Subramani

Andrew Perepelytsya wrote:
Consider ComponentBindings. Then your service could orchestrate complex
flows.

HTH,
Andrew

On Jul 1, 2009 7:07 AM, "deepan s" <deepans@virtusa.com> wrote:


Appreciate your quick response.

Thanks Antoine, what you suggested worked.

We have one more query,

Is there a condition based routing mechanism?
Say, i have 3 services (taking same input parameter) to be routed in order.
And the routing should break and return to the caller when some condition
gets satisfied (condition should be evaluated on the response of the service
being called)

We can achieve the same using exception based routing by throwing an
exception with-in each of the service when the condition is not satisfied
(so that the routing proceeds to the next service), but is there a more
elegant way of doing this without throwing an exception?

Regards,
Deepan Subramani.


Regards,
Deepan Subramani

antoine.borg wrote: > > Hello, > > The chaining router does not catch
exceptions that are thrown...
--
View this message in context:
http://www.nabble.com/exception-type-filter-with-chaining-router-tp24267008p24287951.html
Sent from the Mule - User mailing list archive at Nabble.com.

--------------------------------------------------------------------- To
unsubscribe from this lis...

Re: exception-type-filter with chaining-router

by antoine.borg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Take a look at the examples here:
http://www.mulesource.org/display/MULE2USER/Component+Bindings

HTH

A

deepan s wrote:

> Andrew,
>
> To use component binding for my scenario, i might have to bind more than one
> endpoints (implementing same interface) to my component, so that i can make
> some routing decisions with in the component class implementation.
>
> I can find the below quoted from the mule document, but not sure how
> "With component bindings it is possible to configure multiple interfaces or
> a single interface with a an endpoint bound to one or more Mule endpoints. "
>
> Can you please advice on how my Invoker component class should look like,
> can i do some thing like this...
>
> public class InvokerComponent {
> private HelloInterface[] hello; // i have an array of components bound
> public String invoke(String s) {  // i make routing decisions
>      String result = hello[0].sayHello(s, "English");
>      if(result.equals("xyz")){
>            result = hello[1].sayHello(s, "English");
>      }
>      return result;
> }
> public void setHello(HelloInterface[] hello) {
>     this.hello = hello;
> }
> public HelloInterface[] getHello() {
>      return hello;
> }
> }
>
> Thanks,
> Deepan Subramani
>
>
> Andrew Perepelytsya wrote:
>  
>> Consider ComponentBindings. Then your service could orchestrate complex
>> flows.
>>
>> HTH,
>> Andrew
>>
>> On Jul 1, 2009 7:07 AM, "deepan s" <deepans@...> wrote:
>>
>>
>> Appreciate your quick response.
>>
>> Thanks Antoine, what you suggested worked.
>>
>> We have one more query,
>>
>> Is there a condition based routing mechanism?
>> Say, i have 3 services (taking same input parameter) to be routed in
>> order.
>> And the routing should break and return to the caller when some condition
>> gets satisfied (condition should be evaluated on the response of the
>> service
>> being called)
>>
>> We can achieve the same using exception based routing by throwing an
>> exception with-in each of the service when the condition is not satisfied
>> (so that the routing proceeds to the next service), but is there a more
>> elegant way of doing this without throwing an exception?
>>
>> Regards,
>> Deepan Subramani.
>>
>>
>> Regards,
>> Deepan Subramani
>>
>> antoine.borg wrote: > > Hello, > > The chaining router does not catch
>> exceptions that are thrown...
>> --
>> View this message in context:
>> http://www.nabble.com/exception-type-filter-with-chaining-router-tp24267008p24287951.html
>> Sent from the Mule - User mailing list archive at Nabble.com.
>>
>> --------------------------------------------------------------------- To
>> unsubscribe from this lis...
>>
>>
>>    
>
>  
--

Antoine Borg, Senior Consultant | Tel: +32 28 504 696
ricston Ltd., BP 2, 1180 Uccle, Brussels, BELGIUM

See our full schedule of Mule and Android courses:
http://www.ricston.com/courses/schedules/

email: _antoine.borg_@... <mailto:antoine.borg@...> |
blog: blog.ricston.com <http://blog.ricston.com> | web: ricston.com
<http://www.ricston.com/>



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: exception-type-filter with chaining-router

by deepan s :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Antoine,

The page you had pointed to has an example of binding a single endpoint to a mule component which is already working for me.

But our scenario requires binding MORE THAN ONE ENDPOINT TO A COMPONENT (please see example code in my previous post) - which the mule documentation states to be possible but doesnt provide any samples.

Can you please throw some light on the same.

Regards,
Deepan Subramani.

Thanks,
Deepan Subramani.

antoine.borg wrote:
Take a look at the examples here:
http://www.mulesource.org/display/MULE2USER/Component+Bindings

HTH

A

deepan s wrote:
> Andrew,
>
> To use component binding for my scenario, i might have to bind more than one
> endpoints (implementing same interface) to my component, so that i can make
> some routing decisions with in the component class implementation.
>
> I can find the below quoted from the mule document, but not sure how
> "With component bindings it is possible to configure multiple interfaces or
> a single interface with a an endpoint bound to one or more Mule endpoints. "
>
> Can you please advice on how my Invoker component class should look like,
> can i do some thing like this...
>
> public class InvokerComponent {
> private HelloInterface[] hello; // i have an array of components bound
> public String invoke(String s) {  // i make routing decisions
>      String result = hello[0].sayHello(s, "English");
>      if(result.equals("xyz")){
>            result = hello[1].sayHello(s, "English");
>      }
>      return result;
> }
> public void setHello(HelloInterface[] hello) {
>     this.hello = hello;
> }
> public HelloInterface[] getHello() {
>      return hello;
> }
> }
>
> Thanks,
> Deepan Subramani
>
>
> Andrew Perepelytsya wrote:
>  
>> Consider ComponentBindings. Then your service could orchestrate complex
>> flows.
>>
>> HTH,
>> Andrew
>>
>> On Jul 1, 2009 7:07 AM, "deepan s" <deepans@virtusa.com> wrote:
>>
>>
>> Appreciate your quick response.
>>
>> Thanks Antoine, what you suggested worked.
>>
>> We have one more query,
>>
>> Is there a condition based routing mechanism?
>> Say, i have 3 services (taking same input parameter) to be routed in
>> order.
>> And the routing should break and return to the caller when some condition
>> gets satisfied (condition should be evaluated on the response of the
>> service
>> being called)
>>
>> We can achieve the same using exception based routing by throwing an
>> exception with-in each of the service when the condition is not satisfied
>> (so that the routing proceeds to the next service), but is there a more
>> elegant way of doing this without throwing an exception?
>>
>> Regards,
>> Deepan Subramani.
>>
>>
>> Regards,
>> Deepan Subramani
>>
>> antoine.borg wrote: > > Hello, > > The chaining router does not catch
>> exceptions that are thrown...
>> --
>> View this message in context:
>> http://www.nabble.com/exception-type-filter-with-chaining-router-tp24267008p24287951.html
>> Sent from the Mule - User mailing list archive at Nabble.com.
>>
>> --------------------------------------------------------------------- To
>> unsubscribe from this lis...
>>
>>
>>    
>
>  
--

Antoine Borg, Senior Consultant | Tel: +32 28 504 696
ricston Ltd., BP 2, 1180 Uccle, Brussels, BELGIUM

See our full schedule of Mule and Android courses:
http://www.ricston.com/courses/schedules/

email: _antoine.borg_@ricston.com <mailto:antoine.borg@ricston.com> |
blog: blog.ricston.com <http://blog.ricston.com> | web: ricston.com
<http://www.ricston.com/>



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email