Designing waiting publisher on backpressure – reactive programming

huangapple 未分类评论92阅读模式
英文:

Designing waiting publisher on backpressure - reactive progamming

问题

我使用projectreactor来在Java中以反应式方式开发我的个人项目。让我们看一下下面的图片:

Designing waiting publisher on backpressure – reactive programming

在我的设计中,有一些发布者线程希望将消息发布到flux或通过flux发布消息,还有一些订阅者处理消息。现在,订阅者可能会太慢。因此,我需要一些反压机制。我知道有一些反压策略,但没有一种策略符合我的期望。我希望我的发布者在消息缓冲区(几乎)为空之前只是阻塞(等待)。

那么,如何以反应式的方式实现它呢?

英文:

I use projectreactor to develop in reactive manner in Java my personal project. Let's see on the picture below:

Designing waiting publisher on backpressure – reactive programming

In my design, there are some publisher threads that want to publish messages to the flux or via flux and there are some subscribers that processes messages. And now, it is possible that subscribers will be too slow. Therefore I need some backpressure mechanism. And I know that there are some backpressure strategies but no strategy meets my expectations. I want my publisher just block (wait) until message buffer is (nearly) empty.

So, how to implement it in reactive manner?

答案1

得分: 0

并行活动可以分为两种类型:线程和演员(也称为异步过程)。它们在通信方式上有所不同。Flux 是用于演员的通信对象。它不适用于连接线程。线程与 BlockingQueue 配合良好连接。

英文:

Parallel activities can be of 2 kinds: threads and actors (also called asynchronous procedures). They differ in the way how they communicate. Flux is a communication object for actors. It does not fit to connect threads. Threads are well connected with BlockingQueue.

huangapple
  • 本文由 发表于 2020年8月14日 20:09:45
  • 转载请务必保留本文链接:https://java.coder-hub.com/63412505.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定