This is my x spring integrator: simple material that I use for training ...
<int-file:inbound-channel-adapter id="executionMessageFileInputChannel" directory="file:${fpml.messages.input}" prevent-duplicates="false" filename-pattern="*.xml"> <int:poller fixed-delay="20000" max-messages-per-poll="20"/> </int-file:inbound-channel-adapter> <int:service-activator input-channel="executionMessageFileInputChannel" output-channel="executionMessageFileArchiveChannel" ref="dummyService" method="myMethod"/> <int-file:outbound-channel-adapter id="executionMessageFileArchiveChannel" directory="file:${fpml.messages.archive}" delete-source-files="true" auto-create-directory="true"/>
I could not find a good tutorial on this. Could you tell me a good tutorial for integrating java dsl? Also, please help me convert this from xml to dsl.
UPDATE: (after Gary Response ):
I managed to translate it before that.
@MessagingGateway public interface Archive { @Gateway(requestChannel = "archiveFile.input") void archive(); } @Bean public IntegrationFlow archiveFile() { return IntegrationFlows .from(Files.inboundAdapter(new File(dirPath)) .patternFilter("*.xml") .preventDuplicatesFilter(false), e -> e.poller(Pollers.fixedDelay(20000) .maxMessagesPerPoll(20))) .handle("app","myMethod") .handle(Files.outboundAdapter(new File(outDirPath)).deleteSourceFiles(true).autoCreateDirectory(true)) .get(); }
Just not sure what I'm doing it right. Wrote it, as soon as I translated, check it out.
Tested: getting the following error:
org.springframework.beans.factory.BeanCreationException: error creating bean with name "archiveFile" defined in si.jdsl.App: bean instance through factory method failed; nested exception org.springframework.beans.BeanInstantiationException: instantiate failed [org.springframework.integration.dsl.IntegrationFlow]: factory method 'archiveFile' threw an exception; java.lang.IllegalArgumentException nested exception: "Filter" (Org.s pringframework.integration.file.filters.CompositeFileListFilter@ 48e64352) is already configured for FileReadingMessageSource
Any thoughts?
UPDATE 2:
Thanks, Gary, solved the filter problem: the problem with the service activator. The following is my service activator:
@Bean @ServiceActivator(inputChannel = "archiveFile.input") public Message<File> myMethod (File inputFile){ Map<String, Object> contextHeader = new HashMap<String, Object>(); return new GenericMessage<File>(inputFile, contextHeader); }
Bean initialization failed; org.springframework.beans.factory.UnsatisfiedDependencyException nested exception: Error creating a bean with the name 'myMethod' defined in si.jdsl.App: An unsatisfied dependency is expressed through a constructor argument with index 0 of type [java.io.File] :: Not qualified bean type found [java.io.File] found for dependency: at least 1 bean is expected that qualifies as an autowire candidate for this dependency. Dependency Annotations: {}; nested exception org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualification bean of type [java.io.File] found for a dependency: at least 1 bean is expected that qualifies as a candidate for auto-bracing for this dependency. Dependency Annotations: {}
Please let me know what I am missing?