Spring Integration从1.0.x迁移到2.2.6

时间:2014-04-18 07:01:30

标签: java spring spring-integration

我正在使用spring framework 3.2.8

迁移我的项目,该项目基于spring integration 1.0.x构建到2.2.6

我添加了新的JAR spring-integration-core-2.2.6.RELEASE.jar并删除了旧的,并且还更新了我的applicationContext.xml文件中的xsd。 下面是applicationContext.xml

中添加的xml架构详细信息
<beans:beans xmlns="http://www.springframework.org/schema/integration"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:stream="http://www.springframework.org/schema/integration/stream"
    xmlns:jms="http://www.springframework.org/schema/integration/jms"
    xmlns:httpinvoker="http://www.springframework.org/schema/integration/httpinvoker"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-3.2.xsd
            http://www.springframework.org/schema/integration
            http://www.springframework.org/schema/integration/spring-integration-2.2.xsd">

现在我面临以下案件的一些困难:

下面是一个在SI 1.0.x中运行良好的小部分:

<channel id="msg.incoming">
        <queue capacity="600" />
</channel>

<service-activator input-channel="msg.incoming" ref="consumer"
        method="doPolling">
        <poller task-executor="consumerpool">
            <interval-trigger interval="1" time-unit="SECONDS" />
        </poller>
</service-activator>

<thread-pool-task-executor id="consumerpool"
        core-size="5" max-size="30" keep-alive-seconds="1000" queue-capacity="20" />

现在我希望用SI 2.2.6做同样的事情。在浏览完SI文档之后,我已经用以下内容更新了上面的部分:

<channel id="dnd.incoming">
        <queue capacity="600" />
    </channel>

<service-activator input-channel="dnd.incoming" ref="consumer" method="doDNDScrubbing">
        <poller fixed-delay="1000" />
</service-activator>

但遗憾的是它不起作用,我也无法在SI 2.2.6中配置相似的行为。 我得到以下例外:

BeanDefinitionParsingException: Configuration problem: A <poller> element must include either an <interval-trigger/> or <cron-trigger/> child element.
2014-04-18 11:55:07,254 ERROR main [ContextLoader.initWebApplicationContext] - Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: A <poller> element must include either an <interval-trigger/> or <cron-trigger/> child element.
Offending resource: class path resource [applicationContext.xml]
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:72)
    at org.springframework.integration.config.xml.PollerParser.configureTrigger(PollerParser.java:100)
    at org.springframework.integration.config.xml.PollerParser.parseInternal(PollerParser.java:77)
    at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:59)
    at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
    at org.springframework.integration.config.xml.IntegrationNamespaceHandler.parse(IntegrationNamespaceHandler.java:53)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1438)
    at org.springframework.integration.config.xml.IntegrationNamespaceUtils.configurePollerMetadata(IntegrationNamespaceUtils.java:149)
    at org.springframework.integration.config.xml.AbstractConsumerEndpointParser.parseInternal(AbstractConsumerEndpointParser.java:87)
    at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:59)
    at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
    at org.springframework.integration.config.xml.IntegrationNamespaceHandler.parse(IntegrationNamespaceHandler.java:53)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1438)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:195)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

请帮我解决这个问题。

此致 桑迪普保罗

2 个答案:

答案 0 :(得分:1)

  1. 根本不要使用XSD版本。迁移到新版本会更容易。

  2. 请删除未使用的xmlnses。

  3. <thread-pool-task-executor>应替换为<task:executor>

  4.   

    <poller>元素必须包含<interval-trigger/><cron-trigger/>子元素。

  5. 这是来自Spring Integration&lt; = 2.0的消息,而不是2.2 =&gt;。所以,请确保使用正确的Spring Integration罐。

    所有其他配置都没问题。

答案 1 :(得分:1)

这是一个很大的跳跃(1.0.x到2.2.x)。

这些子元素在2.0中已弃用,在2.1中已删除。

请查看迁移指南2.0->2.12.1->2.23.0.2是当前版本;它的migration guide is here