-
1. Re: Accessing Switchyard context from onCompletion when an exception occurs
kcbabo Aug 7, 2014 11:59 AM (in response to san_ebro)Do you have an error handler registered for the route? Is it possible for you to create a basic app to reproduce this behavior? Something with some dummy services and some code which throws an exception to demonstrate the problem would be fine.
-
2. Re: Re: Accessing Switchyard context from onCompletion when an exception occurs
san_ebro Aug 18, 2014 2:32 AM (in response to kcbabo)Hi,
no, I don't have an errorHandler for the route, I don't have any 'cause I don't need to define redelivery policy. Should I? I'm implicitly handling faults by throwing a HandlerException.
Sure I can attach some code, thank you very much in advance. I defined two services there; one stores a property value on context and throws an exception, and the other one is called onCompletion and tries to retrieve the same property. I get a NullPointerException when trying, while if an exception is not thrown it works fine.
Thank you very much again and best regards.
-
3. Re: Accessing Switchyard context from onCompletion when an exception occurs
kcbabo Aug 14, 2014 2:24 PM (in response to san_ebro)An ErrorHandler is not required, I'm just trying to get a sense for what's in the route definition. Are you able to use another archive format like zip or tar for your attachment?
-
4. Re: Re: Accessing Switchyard context from onCompletion when an exception occurs
san_ebro Aug 18, 2014 2:31 AM (in response to kcbabo)Sure, of course. Sorry for the wrong format.
Thanks.
-
oncompletion_test.zip 21.9 KB
-
-
5. Re: Accessing Switchyard context from onCompletion when an exception occurs
san_ebro Sep 3, 2014 4:43 AM (in response to san_ebro)Am I missing something basic? Any help would be appreciated.
Thanks.
-
6. Re: Re: Accessing Switchyard context from onCompletion when an exception occurs
kcbabo Sep 3, 2014 5:01 PM (in response to san_ebro)Thanks for the reproducer application. I have attached a slightly tweaked version which demonstrates two things:
1) Context properties set earlier in the route are available in onCompletion whether an exception is thrown or not.
2) Context properties set in a service which throws an exception are not available.
Point #1 seems to be at odds with your original report in this thread. Take a look at the modified example (I added a test as well, so just running "mvn test" will run the route) and let me know if I have something wrong. I modified the route to call the GetContextService twice - the first call sets a property and the second call attempts to read that property along with the one set in ThrowExceptionService.
Point #2 is due to this logic:
components/CamelResponseHandler.java at master · jboss-switchyard/components · GitHub
Before filing a JIRA around #2, I will wait for you to confirm that #1 is working as expected.
-
oncompletion_test2.zip 9.7 KB
-
-
7. Re: Re: Re: Accessing Switchyard context from onCompletion when an exception occurs
san_ebro Sep 10, 2014 8:27 AM (in response to kcbabo)Hi,
thank you very much for your response. You're completely right, earlier services stores correctly properties on context; it's the exception thrower which doesn't. I'm sorry about the wrong description. Your scenario works completely fine. Thanks million.
Working on it on my own I think I've found another strange behavior. I've defined an earlier service to set one context property, which is invoked before the one that throws the exception. More or less what you did, thank you again. I've found if the method setting the property is a void method, the property is not set on successive services. If it returns something (String, for example), the property is set. Should this be corrected also? It's not critical for me right now, but I though it would be good for you to know. I'm attaching the scenario.
Thank you very much again.
-
oncompletion_test3.rar 21.2 KB
-