【问题标题】:Vert.x WriteStream setWriteQueueMaxSizeVert.x WriteStream setWriteQueueMaxSize
【发布时间】:2020-05-29 16:49:45
【问题描述】:

我是 Vert.x 的新手。当我从https://vertx.io/docs/vertx-core/java/阅读文章中的writestream时如下:

setWriteQueueMaxSize: set the number of object at which the write queue is
 considered full, and the method writeQueueFull returns true. Note that, 
when the write queue is considered full, if write is called the data will 
still be accepted and queued. The actual number depends on the stream 
implementation, for Buffer the size represents the actual number of bytes 
written and not the number of buffers.

尤其是这句话——“请注意,当写入队列被认为已满时,如果调用写入数据仍将被接受并排队。”,从这句话中,我有几个问题:

(1) 写入流有大小限制吗?我的意思是,例如事件总线,可以向事件总线写入多少消息?它取决于内存吗?假设我继续将消息写入事件总线并且消息没有被消耗,这是否会导致 Java 中的内存不足?

(2) 如果写入有一些限制,我在哪里以及如何检查默认队列大小?比如想知道Vert.x KafkaProducer的默认队列大小,在哪里可以查看?

感谢任何想法。

【问题讨论】:

    标签: vert.x


    【解决方案1】:

    那里实际上有三个不同的问题,但无论如何我都会试一试:

    写入流有大小限制吗?

    这取决于流的实现。但是我还没有看到一个实际使用WriteQueueMaxSize的实现@

    可以向事件总线写入多少消息?是否依赖内存?

    EventBus 是一个特例。如果没有人从 EventBus 消费,它只会丢弃消息,因此在这种微不足道的情况下,可以写入无限个数。但是如果有消费者,而且他们很慢,是的,最终你会耗尽内存。 EventBus 实现目前对WriteQueueMaxSize没有任何作用

    如果写入有一些限制,我可以在哪里以及如何检查默认队列大小?比如想知道Vert.x KafkaProducer的默认队列大小,在哪里可以查看?

    所有 Vert.x 项目都是开源的,所以你通常会在 GitHub 上找到它们(或其他开源存储库,但实际上我不记得任何不在 GitHub 上的项目)。

    特别是对于 Vert.x KafkaProducer,您可以在此处查看代码:

    https://github.com/vert-x3/vertx-kafka-client/blob/1720d5a6792f70509fd7249a47ab50b930cee7a7/src/main/java/io/vertx/kafka/client/producer/impl/KafkaProducerImpl.java#L217

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-11
      • 1970-01-01
      • 2014-07-18
      • 2014-08-15
      • 2014-04-08
      • 1970-01-01
      • 2017-05-20
      • 2018-05-22
      相关资源
      最近更新 更多