问题描述
我们有一个用于春季云数据流的POC,我们应该从本地路径中选择一个csv文件并将其流传输到接收器。 @inboundChannelAdapter方法每10秒轮询一次。 在本地通过数据流仪表板创建流时,我能够将文件数据从源流传输到接收器。
但是,如果我在流运行时修改/删除文件内容,则在10秒轮询间隔后它不会从路径中选择更新的文件。似乎最初是在开始拾取文件时(创建流并运行jar时),然后在每个轮询间隔从临时/本地缓存路径中拾取了相同的文件。可能我在这里错过了一些非常基本的东西。
这是我的源类:
@EnableBinding(Source.class)
public class SourceServiceBean {
@Bean
@InboundChannelAdapter(value=Source.OUTPUT,poller = @Poller(fixedDelay = "10000"))
public MessageSource<List<String>> addSourceData() throws IOException {
List<String> stringList = new ArrayList<String>();
String s = "C:\\Users\\123456\\Documents\\Sample1.csv";
FileReader in = new FileReader(s);
try(BufferedReader br = new BufferedReader(in)) {
for(String line; (line = br.readLine()) != null; ) {
stringList.add(line);
}
br.close();
// line is not visible here.
}
in.close();
return () -> MessageBuilder.withPayload(stringList).build();
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)