gpt4 book ai didi

java - Spring Integration,更改 udp-outbound-channel 端口

转载 作者:行者123 更新时间:2023-11-30 08:08:06 25 4
gpt4 key购买 nike

我正在使用 Spring 集成以 UDP 发送文件行。这是我正在做的事情:

<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>

因此,它从存储库中获取文件列表,将文件分成几行,然后在端口 11111 上发送该行。

我想做的是根据文件的扩展名在预定义端口上发送行:

  • *.txt 文件的所有行都将通过端口 11111 发送
  • *.csv 文件的所有行都将通过端口 11112 发送
  • 等等

谢谢!

最佳答案

谢谢加里!

这是我的操作方法:

<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:chain input-channel="inputFiles">
<int:header-enricher>
<int:header name="extension"
expression="payload.getName().substring(payload.getName().lastIndexOf('.'))" />
</int:header-enricher>
<int:splitter>
<bean class="fr.spring.demo.FileSplitter">
<property name="commentPrefix" value="#" />
</bean>
</int:splitter>
<int:router expression="headers.extension">
<int:mapping value=".gps" channel="udpChannel_11111" />
<int:mapping value=".ths" channel="udpChannel_11112" />
</int:router>
</int:chain>

<int:channel id="udpChannel_11111" />
<int:channel id="udpChannel_11112" />
<int-ip:udp-outbound-channel-adapter
channel="udpChannel_11111" host="192.168.0.1" port="11111" />
<int-ip:udp-outbound-channel-adapter
channel="udpChannel_11112" host="192.168.0.1" port="11112" />

关于java - Spring Integration,更改 udp-outbound-channel 端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30802106/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com