Spring Integration:对Web服务的JDBC单一查询

时间:2014-12-03 10:59:59

标签: spring-mvc soap integration spring-integration spring-ws

我想知道解决此集成方案的方法:

  • 执行不同的查询以从数据库中选择X元素。我是 寻找一个没有池的入站适配器,因为它只是 执行一次查询所必需的。虽然,查询的结果 将只生成一个输出。
  • 使用此数据构建S​​OAP请求(通用Web服务)
  • 将此SOAP请求发送到Web服务并等待异步响应。

但是,有必要将所有这些场景部署在Tomcat服务器上的WAR文件中。我正在从弹簧MVC +弹簧集成框架部署应用程序,但我不会有任何控制器。在Tomcat上加载上下文时是否可以执行应用程序?

我正在使用下一代技术:

  • Spring集成
  • 用于WAR部署的Spring MVC
  • 计划(Quartz或@Scheduled)
  • Spring WS

此致

1 个答案:

答案 0 :(得分:0)

由于您说您在应用程序启动时只想select而且只有一次,您可以使用:

<int-event:inbound-channel-adapter channel="jdbcChannel" 
       event-types="org.springframework.context.event.ContextRefreshedEvent"
       payload-expression="''"/>

<int-jdbc:outbound-gateway query="SELECT * FROM ..."/>

依此类推WebService。

<强>更新

由于您说您在Anotation配置周围,请考虑使用Spring Integration Java DSL

要从<int-event:inbound-channel-adapter>配置@Configuration,您应该这样做:

    @Bean
    @SuppressWarnings("unchecked")
    public MessageProducer ApplicationEventListeningMessageProducer() {
        ApplicationEventListeningMessageProducer producer = new ApplicationEventListeningMessageProducer();
        producer.setEventTypes(ContextRefreshedEvent.class);
        producer.setPayloadExpression("''");
        producer.setOutputChannel(jdbcChannel());
        return producer;
    }

ContextRefreshedEvent您可以从JavaDocs或Spring Framework Manual获取信息。