【发布时间】:2018-03-24 12:22:19
【问题描述】:
有没有人用 DSL 完成 spring-integration-jdbc StoredProcOutboundGateway 配置?
【问题讨论】:
标签: spring spring-integration spring-integration-dsl
有没有人用 DSL 完成 spring-integration-jdbc StoredProcOutboundGateway 配置?
【问题讨论】:
标签: spring spring-integration spring-integration-dsl
没有用于 JDBC 的 Spring Integration Java DSL。请随时就此事提出JIRA。
作为解决方法,我们真的别无选择,除非使用通用 .handle() EIP 方法中的 StoredProcOutboundGateway 类:
@Bean
public StoredProcExecutor storedProcExecutor() {
StoredProcExecutor storedProcExecutor = new StoredProcExecutor(this.dataSource);
storedProcExecutor.setStoredProcedureName("CREATE_USER_RETURN_ALL");
storedProcExecutor.setIsFunction(true);
...
return storedProcExecutor;
}
...
StoredProcOutboundGateway storedProcOutboundGateway = new StoredProcOutboundGateway(storedProcExecutor());
storedProcOutboundGateway.setExpectSingleResult(true);
storedProcOutboundGateway.setRequiresReply(true);
...
.handle(storedProcOutboundGateway)
【讨论】:
StoredProcExecutor。有关更多信息,请参阅其 JavaDocs。如果你需要setStoredProcedureNameExpression(Expression),你应该看看SpelExpressionParser:docs.spring.io/spring/docs/5.0.0.RELEASE/…。对于消息中的参数,您应该使用setProcedureParameters(List<ProcedureParameter>) 并使用它的expression。请就此事提出 JIRA 以向 Docs 添加示例:jira.spring.io/browse/INT