如何重新启动或停止/继续响应式消息传递,例如改变间隔时间之后? 这个例子来自Quarkus指南:https://quarkus.io/guides/kafka-streams
@Outgoing("temperature-values")
public Flowable<KafkaRecord<Integer, String>> generate() {
return Flowable.interval(500, TimeUnit.MILLISECONDS)
.onBackpressureDrop()
.map(tick -> {
WeatherStation station = stations.get(random.nextInt(stations.size()));
double temperature = BigDecimal.valueOf(random.nextGaussian() * 15 + station.averageTemperature)
.setScale(1, RoundingMode.HALF_UP)
.doubleValue();
LOG.infov("station: {0}, temperature: {1}", station.name, temperature);
return KafkaRecord.of(station.id, Instant.now() + ";" + temperature);
});
}
答案 0 :(得分:1)
您可以尝试将TextureResource.load()
替换为Flowable
,并使用Subject
将值输入Flowable
本身。然后,当您要替换所需的内容时,将删除当前的Subject
并创建新的Flowable
Subject