smallrye-reactive-messaging
smallrye-reactive-messaging copied to clipboard
Pulsar backpressure mechanism ignores client's memory limit setting
In reference to the discussion from this issue https://github.com/smallrye/smallrye-reactive-messaging/issues/2548#issuecomment-2037205262
The backpressure mechanism in the SmallRye Pulsar connector does not consider memory limit settings. While Pulsar clients can be configured with memoryLimitBytes
, which is shared among all consumers and producers used by the client, the backpressure mechanism solely relies on the maxPendingMessages
set for the producer. Consequently, it will refrain from sending more messages to the producer queue. However, disregarding the memory limit may result in a MemoryBufferIsFullError
if a certain number of messages (lower than maxPendingMessages
) with large payload sizes exceed memoryLimitBytes
.
In order to address this, backpressure should also verify whether the client can reserve memory for the message to be sent via the producer. This could be achieved by introducing a new processor, such as the MemoryLimitAwareSendProcessor
, which would check memory availability before sending the message to the producer.