Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Pulsar Java client taking too much memory (OOM)

I wrote a simple Apache Pulsar client with Spring boot - a pulsar-producer initialized as beans that will be used in the rest controller to publish incoming api messages to Pulsar, and a consumer that consumes message, prints some values in console & acknowledge.

As of now the application is very simple, but the moment this spring-boot app loads I see memory peak, at times getting OOM. Is there any specific configuration to be used when using Pulsar client with Spring-boot?

The code is mostly the one found the Pulsar doc.

like image 684
Vijay Veeraraghavan Avatar asked Jun 28 '26 00:06

Vijay Veeraraghavan


1 Answers

I am answering this to doc this issue - do not use the loops to consume messages, instead adopt the MessageListener subscribed to consumer via

consumer.messageListener(new Myconsumer())

or

consumer.messageListener((consumer, msg)->{//do something})

Docs didnt mention this, but I found surfing the consumer api.

like image 118
Vijay Veeraraghavan Avatar answered Jul 05 '26 05:07

Vijay Veeraraghavan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!