I'm using spring integration to send line of files in UDP. Here is what I'm doing:
<int-file:inbound-channel-adapter
prevent-duplicates="false" id="filesIn" directory="file:input"
channel="inputFiles">
<int:poller default="true" fixed-rate="1000" />
</int-file:inbound-channel-adapter>
<int:splitter input-channel="inputFiles" output-channel="output">
<bean class="fr.spring.demo.FileSplitter">
<property name="commentPrefix" value="#" />
</bean>
</int:splitter>
<int:transformer input-channel="output" expression="payload"
output-channel="exampleChannel" />
<int:channel id="exampleChannel" />
<int-ip:udp-outbound-channel-adapter
id="udpOut" channel="exampleChannel" host="192.168.0.1" port="11111">
</int-ip:udp-outbound-channel-adapter>
So it takes a list of files from a repertory, splits the file in lines and sends the line on port 11111.
What I would like to do, is to send the lines on a predefined port depending on the extension of the file:
- All the lines of *.txt files will be sent on port 11111
- All the lines of *.csv files will be sent on port 11112
- And so on
Thanks!
It is not currently possible to select the port based on the message; please feel free to open a new feature JIRA Issue.
In the meantime, you can declare two adapters, one with each port, and add a router upstream to route to one or the other based on the file extension.