pulsar4s icon indicating copy to clipboard operation
pulsar4s copied to clipboard

SendAsync

Open pmcvay opened this issue 4 years ago • 3 comments

(I apologize for this question as I am a beginner to scala)

Is there an example anywhere on how to use sendAsync?

I am trying to do the following: if sCol is a collection on strings Then I would like to do sCol.map(producer.sendAsync(_)) wait until all complete

pmcvay avatar Sep 07 '21 19:09 pmcvay

Or does the default send use batching without waiting?

pmcvay avatar Sep 07 '21 21:09 pmcvay

If I just do sCol.map(producer.send(_)), then it is terribly slow so I do not think the messages are being batched

pmcvay avatar Sep 08 '21 01:09 pmcvay

Your last example will send one at a time. You can sendAsync then collect all the futures using .sequence and then await on that.

sksamuel avatar Sep 08 '21 02:09 sksamuel