I am working on a project in spring boot and I need to add Spring integration poller for polling files from a location and run spring batch on that file to process it.
I have used spring batch integration for this(Document Reference below.)
http://docs.spring.io/spring-batch/trunk/reference/html/springBatchIntegration.html
In spring boot, I have succesfully configured my poller in @Configuration file as below
@Bean
@InboundChannelAdapter(value = "fileInputChannel", poller = @Poller(
fixedRate = "1000"), autoStartup = "true")
public MessageSource<File> filesScanner() {
CompositeFileListFilter<File> filters = new CompositeFileListFilter<File>();
filters.addFilter(new SimplePatternFileListFilter("*.xml"));
filters.addFilter(new AcceptOnceFileListFilter<File>());
filters.addFilter(getLastModifiedFileFilter());
FileReadingMessageSource source = new FileReadingMessageSource();
source.setDirectory(new File("F:/DataInput/"));
source.setFilter(filters);
return source;
}
This poller is defined in java configuration whereas the channels are defined in xml as below.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-file="http://www.springframework.org/schema/integration/file"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/file
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd">
<int:channel id="ticketingResponse" />
<int:channel id="mailFailureTicketData" />
<int:channel id="moveSuccessTicketingFile" />
<int:channel id="moveFailureTicketingFile" />
<int:channel id="ticketingFileInput" />
<int:channel id="ticketingJobParameters" />
<!-- <int-file:inbound-channel-adapter id="filePoller"
channel="inboundFileChannel"
directory="file:/tmp/myfiles/"
filename-pattern="*.csv">
<int:poller fixed-rate="1000"/>
</int-file:inbound-channel-adapter> -->
<bean id="earliestTicketingFileSelecter" class="com.avios.integration.iqcx.FilesSortingComparator" />
<bean id="compositeFilesFilter"
class="org.springframework.integration.file.filters.CompositeFileListFilter">
<constructor-arg>
<list>
<bean
class="org.springframework.integration.file.filters.RegexPatternFileListFilter">
<constructor-arg name="pattern" value="${ticketing.input.file.pattern}" />
</bean>
<bean class="org.springframework.integration.file.filters." />
<bean
class="org.springframework.integration.file.filters.LastModifiedFileListFilter">
<property name="age" value="${ticketing.input.file.age}" />
</bean>
</list>
</constructor-arg>
</bean>
<bean id="ticketingFilesScanner"
class="org.springframework.integration.file.FileReadingMessageSource">
<property name="filter" value="compositeFilesFilter" />
<property name="directory" value="/tmp/myfiles/" />
</bean>
<int-file:inbound-channel-adapter id="filePoller"
channel="inboundFileChannel"
directory="file:/tmp/myfiles/"
filename-pattern="*.csv">
<int:poller fixed-rate="1000"/>
</int-file:inbound-channel-adapter><!-- <int-file:inbound-channel-adapter
directory="${ticketing.input.file.path}" channel="ticketingFileInput"
comparator="earliestTicketingFileSelecter" auto-startup="true" filter="compositeFilesFilter" >
<int:poller ></int:poller>
</int-file:inbound-channel-adapter> -->
<int:transformer id="iqcxFilesToJobParameters" ref="jobParameterTransformer"
input-channel="ticketingFileInput" method="addTicketingFileToJobParameter"
output-channel="ticketingJobParameters" />
<int:outbound-channel-adapter channel="ticketingJobParameters"
ref="iqcxJobLaunchingGateway" method="handleMessage" />
</beans>
I am getting the below error in my XML configuration file.
cvc-complex-type.3.2.2: Attribute 'fixed-rate' is not allowed to appear in element 'int:poller'.
I checked this on google and found only the below link which wasn't much of use as i am getting exact same error.
Using Spring Boot & Spring Integration with database backed Configuration
Attribute 'fixed-rate' is not allowed to appear in element 'int:poller'
Spring boot version i am using is as below.
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.6.RELEASE</version>
Spring integration jar in library - Spring-integration-core-4.2.8.RELEASE.jar
I also tried excluding integration jar from batch-integration dependency and adding it separately as below but that didn't work either.
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-integration</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.integration/spring-integration-core -->
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
</dependency>
Also checked the XSD http://www.springframework.org/schema/integration/spring-integration.xsd and it has the attribute fixed-delay in poller. Any suggestions for resolving this?
Read the important note in the online schema:
In the old schema, fixed-rate was part of a periodic trigger child element on the poller.
The 4.2 schema is here.
If this is just an IDE error, you can ignore it, or configure your IDE to be "spring aware".
Spring finds the actual schema on the classpath.
With STS, enable "spring nature" on the project.
sometimes it could be due to missing spring-boot-starter-integration & spring-integration-file dependency in pom.xml. So check if actually spring-integration-file dependency is available in your project when you are using spring integration.