我的 fileMessageProvider() 作为
@InboundChannelAdapter( value = "files" , poller = @Poller( fixedDelay = "${my.poller.interval}", maxMessagesPerPoll = "1" ))
public Message<File> fileMessageProvider() {
...
}
部署时给出 NumberFormatException
Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myPoller' defined in "../MyPoller.class": Initialization of bean failed; nested exception is java.lang.NumberFormatException: For input string: "{#my.poller.interval}"
如果我使用fixedDelay =“10000”而不是SpEL,它效果很好。
我的 Spring 集成版本“4.0.0.RELEASE”
Update:1
我混合使用注释和 xml 配置
批次属性
my.poller.interval=20000
集成上下文.xml
<context:property-placeholder location="classpath:Batch.properties"/>
<context:component-scan base-package="com.org.reader" />
<int:transformer input-channel="files" output-channel="requests">
<bean class="com.org.reader.MyMessageToJobRequest">
<property name="job" ref="addMessages"/>
</bean>
</int:transformer>
自从这个功能提出以来,我们在这个问题上有类似的测试用例:
@Override
@ServiceActivator(inputChannel = "input", outputChannel = "output",
poller = @Poller(maxMessagesPerPoll = "${poller.maxMessagesPerPoll}", fixedDelay = "${poller.interval}"))
@Publisher
@Payload("#args[0].toLowerCase()")
@Role("foo")
public String handle(String payload) {
return payload.toUpperCase();
}
但是是的:我必须确认如果我们指定它会停止正常工作<context:property-placeholder>
在 XML 配置中而不是@PropertySource
on the @Configuration
class.
我不记得关于此事的特定 JIRA,但我记得通过注释和 XML 配置混合,第一个具有优先级,并且必须在@Configuration
class.
对于我的示例,它看起来像:
@Configuration
@ComponentScan
@IntegrationComponentScan
@EnableIntegration
@PropertySource("classpath:org/springframework/integration/configuration/EnableIntegrationTests.properties")
@ImportResource("classpath:org/springframework/integration/configuration/EnableIntegrationTests-context.xml")
@EnableMessageHistory({"input", "publishedChannel", "annotationTestService*"})
public class ContextConfiguration {
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
UPDATE
从另一方面,我发现了如何从框架的角度使其工作。
所以,这是一个错误,我正在提出一个JIRA https://jira.spring.io/browse/INT-3853就此事。
感谢您分享您的经验!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)