file:inbound-channel-adapter with nio-locker and file-to-string-transformer
Hi everybody,
Using inbound-channel-adapter, locking the file with nio-locker cause file-to-string-transformer not able to access the file anymore.
I thought that the file locked would be still accessible by the thread that has taken the lock to transform it and then delete it.
I am wrong?
Here is my config:
Code:
<int-file:inbound-channel-adapter
channel="fileToStringChannel"
directory="file:c:/temp/scm"
prevent-duplicates="true">
<int:poller id="poller" fixed-delay="1000">
<int:transactional transaction-manager="txManager"/>
</int:poller>
<int-file:nio-locker/>
</int-file:inbound-channel-adapter>
<int-file:file-to-string-transformer
input-channel="fileToStringChannel"
output-channel="stringToEnricherChannel"
charset="UTF-8"
delete-files="false"/>
<int:header-enricher
input-channel="stringToEnricherChannel"
output-channel="dispatchChannel">
<int:header name="correlationId" ref="messageCoreKeyExtractor" method="extractKey"/>
<int:header name="JMSXGroupID" ref="messageCoreKeyExtractor" method="extractKey"/>
</int:header-enricher>
<int-jms:outbound-channel-adapter order="1"
channel="dispatchChannel"
connection-factory="cachedConnectionFactory"
destination-name="outQueue"
header-mapper="defaultJmsHeaderMapper"/>
<!-- If JMS Send was successful, remove the file (within the transaction)
http://forum.springsource.org/showthread.php?102004-File-Channel-Adapter-issues-->
<int:service-activator order="2"
input-channel="dispatchChannel"
output-channel="nullChannel"
expression="headers.file_originalFile.delete()"/>
<!-- Channels -->
<int:channel id="fileToStringChannel"/>
<int:channel id="stringToEnricherChannel"/>
<int:publish-subscribe-channel id="dispatchChannel"/>
<!-- Beans-->
<bean id="messageCoreKeyExtractor" class="com.xxx.integration.MessageCoreKeyExtractor"/>
<bean id="defaultJmsHeaderMapper" class="org.springframework.integration.jms.DefaultJmsHeaderMapper"/>
<!-- JMS connection factory and tx manager-->
<bean id="cachedConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory"
p:targetConnectionFactory-ref="connectionFactory"
p:sessionCacheSize="5"
p:cacheProducers="false"/>
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"
p:brokerURL="failover://(${broker.url})?jms.prefetchPolicy.all=1" />
<bean id="txManager" class="org.springframework.jms.connection.JmsTransactionManager"
p:connectionFactory-ref="connectionFactory"/>