2015-06-03 38 views
1


豆和方法名VS拉姆達在Spring集成的Java DSL

有在Spring集成的Java的Dsl的方式,使這個:

@Bean 
IntegrationFlow serviceFlow() { 
    return IntegrationFlows 
     .from("inputChannel") 
     .handle(File.class, (p,h) -> someService.someMethod(p)) 
     .channel("someChannel") 
     .get(); 
} 

這樣的表現:

@Bean 
IntegrationFlow serviceFlow() { 
    return IntegrationFlows 
     .from("inputChannel") 
     .handle("someService","someMethod") 
     .channel("someChannel") 
     .get(); 
} 

當談到異常處理?

第一個版本拋出:

2015-06-03 23:30:42.912 ERROR 6251 --- [ask-scheduler-1] o.s.integration.handler.LoggingHandler : org.springframework.messaging.MessageHandlingException: ; nested exception is java.lang.reflect.InvocationTargetException 
at org.springframework.integration.dsl.LambdaMessageProcessor.processMessage(LambdaMessageProcessor.java:129) 
at org.springframework.integration.handler.ServiceActivatingHandler.handleRequestMessage(ServiceActivatingHandler.java:71) 
(...) 
Caused by: java.lang.reflect.InvocationTargetException 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
(...) 
Caused by: java.lang.RuntimeException: error from service 
at com.lukzar.SomeService.someMethod(SomeService.java:15) 
at com.lukzar.IntegrationConfiguration.lambda$serviceFlow$1(IntegrationConfiguration.java:48) 
at com.lukzar.IntegrationConfiguration$$Lambda$2/1367672657.handle(Unknown Source) 
(...) 

和版本beanName和方法名拋出:

2015-06-03 23:27:45.841 ERROR 6177 --- [ask-scheduler-1] o.s.integration.handler.LoggingHandler : org.springframework.messaging.MessageHandlingException: ; nested exception is java.lang.RuntimeException: error from service 
at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:78) 
at org.springframework.integration.dsl.support.BeanNameMessageProcessor.processMessage(BeanNameMessageProcessor.java:57) 
(...) 
Caused by: java.lang.RuntimeException: error from service 
at com.lukzar.SomeService.someMethod(SomeService.java:15) 
(...) 

回答

0

如果通過 「行爲像」 你的意思是讓error from service例外第一cause,那麼我們就可以看看從堆棧跟蹤中刪除InvocationTargetException。這將使潛在的例外MessageHandlingExceptioncause

如果你的意思是使堆棧跟蹤完全相同,那麼沒有。

如果您的意思是前者,請打開JIRA IssueJavaDSL組件,我們來看看。

+0

是的,我覺得它像第一個。我打開了一個JIRA問題。 –