重新启动响应消息,例如重新配置后

时间:2020-06-06 19:00:44

标签: quarkus smallrye-reactive-messaging

如何重新启动或停止/继续响应式消息传递,例如改变间隔时间之后? 这个例子来自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);
            });
}

1 个答案:

答案 0 :(得分:1)

您可以尝试将TextureResource.load()替换为Flowable,并使用Subject将值输入Flowable本身。然后,当您要替换所需的内容时,将删除当前的Subject并创建新的Flowable

Subject