[英]Spring cloud stream and backpressure using PubSubReactiveFactory
I am trying to implement a flow control similar to https://cloud.google.com/pubsub/docs/pull#flow_control using spring cloud stream reactive client.我正在尝试使用 spring 云 ZF7B44CFAFD5C52223D5498196C8A2E7B 实现类似于https://cloud.google.com/pubsub/docs/pull#flow_control的流控制。
@Bean
ApplicationRunner reactiveSubscriber(PubSubReactiveFactory reactiveFactory, PubSubMessageConverter converter) {
return (args) -> {
reactiveFactory.poll("orders-subscription", 250L)
// Convert a JSON payload into an object
.map(msg -> converter.fromPubSubMessage(msg.getPubsubMessage(), Order.class))
.doOnNext(order -> proccessOrder(order))
// Mannually acknowledge the message
.doOnNext(AcknowledgeablePubsubMessage::ack);
.subscribe();
};
}
It seems that back-pressure is not possible to limit number of data flowing through the system.似乎背压无法限制流经系统的数据数量。 Since the processing can last for few second I am afraid to cause some memory problems with high number of incoming message (millions of incoming message per day).由于处理可以持续几秒钟,我担心会导致一些 memory 问题与大量传入消息(每天数百万条传入消息)有关。
What I would like to achieve is a constant processing of 100 messages in the flux.我想要实现的是不断处理不断变化的 100 条消息。 Anyone had success implement it?有人成功实施了吗? Maybe reactive rabbitmq?也许反应 rabbitmq?
resolved using spring amqp and prefetch count.使用 spring amqp 和预取计数解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.