2017-03-17 32 views
0

我在我的项目中使用了Spring集成。我有一个存储过程插入一行并且不返回任何结果。如果我使用int-jdbc:stored-proc-outbound-gateway,流程将简单终止并且不会连接到下一个通道。处理不返回任何结果的存储过程的最佳方法

DEBUG [org.springframework.jdbc.core.JdbcTemplate.doInCallableStatement] CallableStatement.execute() returned 'false' 
DEBUG [org.springframework.jdbc.core.JdbcTemplate.doInCallableStatement] CallableStatement.getUpdateCount() returned 0 
DEBUG [org.springframework.jdbc.core.JdbcTemplate.extractReturnedResults] CallableStatement.getUpdateCount() returned -1 

我的要求是即使存储过程没有返回任何结果,也要继续流程。什么是最好的处理方式?

UPDATE

阿尔乔姆的响应后,我已经配置以下面的方式存储的过程的出站信道适配器:

<int:service-activator ref="msgHandler" method="buildRequestBasedDataSource" input-channel="PQPutUserBAInformation-SPCall2" output-channel="PQPutUserBAInformation-publishSubscribeChannel"/> 
    <!-- PQPutUserBAInformation Channel --> 

     <int:publish-subscribe-channel id="PQPutUserBAInformation-publishSubscribeChannel" /> 

     <int-jdbc:stored-proc-outbound-channel-adapter 
         id="PQPutUserBAInformation-AWD-StoredProcedure2" 
         channel="PQPutUserBAInformation-publishSubscribeChannel" 
         data-source="routingDataSource" 
         stored-procedure-name="ZSPPQINSERTUSERIDBA" 
         ignore-column-meta-data="true" 
         use-payload-as-parameter-source = "false" > 

         <int-jdbc:sql-parameter-definition name="P_USERID" direction="IN" type="VARCHAR" /> 

         <int-jdbc:parameter name="P_USERID" expression="#xpath(payload, '//CurrentUserID')" /> 
     </int-jdbc:stored-proc-outbound-channel-adapter> 

     <!-- Service Activator to build the Message from the Stored Procedure ResultSet --> 
    <int:service-activator input-channel="PQPutUserBAInformation-publishSubscribeChannel" ref="msgHandler" method="buildMessageFromExtSysResponse" />  
+0

重复的问题。看这里。我问同样的东西:) http://stackoverflow.com/questions/42676147/spring-integration-chain-flow-handling-void-gateway-calls/42676419#42676419 – haju

+0

如果我的存储过程在插入过程中失败记录,那么我需要错误信息。所以,在这种情况下,你的问题可能无法帮助我。 –

+0

您是否在捕获存储过程中的异常并吞下它?您应该能够将oracle异常传播回网关,然后使用错误通道。这就是我为我的错误所做的。 – haju

回答

1

考虑使用stored-proc-outbound-channel-adapter代替。

要在此之后继续此流程,您应该考虑使用publish-subscribe-channel作为该适配器的输入。并让更多的用户在流中继续前进。

实现相同行为的另一种方法是recipient-list-router

+0

对不起,我的延迟响应。这些日子我一直在度假。我已经添加了'int-jdbc:stored-proc-outbound-channel-adapter'和'int:publish-subscribe-channel',但是我收到了异常,java.lang.IllegalArgumentException:提供了输出通道,但是链中的最终处理程序不会实现MessageProducer接口。' –

+1

您没有告诉我们您使用'chain'。当然,如果你打算使用出站通道适配器 –

+0

,那么你必须打破它。我很抱歉没有告诉你我正在使用'chain'组件。如何指定'stored-proc-outbound-channel-adapter'的输入和输出通道。我第一次使用它。请你分享一个例子吗?还有一件事,我忘了告诉你,我有时可能会从存储过程中得到结果(ResultSet),有时候不会。那么,你能否建议我如何处理这种情况? –