【问题标题】:Spring-integration-jdbc StoredProcOutboundGateway with DSLSpring-integration-jdbc StoredProcOutboundGateway 与 DSL
【发布时间】:2018-03-24 12:22:19
【问题描述】:

有没有人用 DSL 完成 spring-integration-jdbc StoredProcOutboundGateway 配置?

【问题讨论】:

    标签: spring spring-integration spring-integration-dsl


    【解决方案1】:

    没有用于 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)
    

    【讨论】:

    • 感谢@Arthem,为了快速响应,我们是否有一个示例代码,其中包含 Java 代码中 StoredProcOutboundGateway 的所有方面,而不是 xml 配置。我有一个用例,其中存储过程和参数的名称将成为消息头的一部分,我希望利用 SpEL。这可以通过java代码(不是XML)来完成。我们有任何参考或单元测试代码吗?
    • 嗯,是的......不幸的是没有。但是应该清楚的是,这里的一切都取决于StoredProcExecutor。有关更多信息,请参阅其 JavaDocs。如果你需要setStoredProcedureNameExpression(Expression),你应该看看SpelExpressionParserdocs.spring.io/spring/docs/5.0.0.RELEASE/…。对于消息中的参数,您应该使用setProcedureParameters(List<ProcedureParameter>) 并使用它的expression。请就此事提出 JIRA 以向 Docs 添加示例:jira.spring.io/browse/INT
    • 感谢@Arthem,您的指导很有帮助。按照您提供的文档参考。现在我有了带有 IntegrationFlow 的 jdbc 组件,就像魅力一样工作。
    • 太棒了!现在是时候接受帮助他人的答案了:stackoverflow.com/help/someone-answers
    • 另见 jira.spring.io/browse/INT-4529 了解相关的 Jira 问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-22
    • 1970-01-01
    • 2017-12-23
    • 1970-01-01
    • 2015-01-29
    • 1970-01-01
    相关资源
    最近更新 更多