问题
I have my fileMessageProvider() as
@InboundChannelAdapter( value = "files" , poller = @Poller( fixedDelay = "${my.poller.interval}", maxMessagesPerPoll = "1" ))
public Message<File> fileMessageProvider() {
...
}
Gives NumberFormatException upon deployment
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}"
Instead of SpEL If I use fixedDelay = "10000" , it works good.
My Spring integration version '4.0.0.RELEASE'
Update:1
I am using a mix of annotation and xml configuration
Batch.properties
my.poller.interval=20000
integration-context.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>
回答1:
We have similar test-case on the matter and exactly since the raise of this feature:
@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();
}
But yes: I have to confirm that it stops to work properly if we specify <context:property-placeholder>
in the XML config instead of @PropertySource
on the @Configuration
class.
I can't recall the particular JIRA on the matter, but I remember that with the annotation and XML configuration mix, the first one has precedence and the environment must be configured in the @Configuration
class.
For my sample it looks like:
@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
From other side I found how to make it working from the Framework perspective.
So, it is a bug and I'm raising a JIRA on the matter.
Thank you for sharing your experience!
来源:https://stackoverflow.com/questions/33149198/spring-integration-spel-issues-with-annotation