3

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.

vvra
  • 2,832
  • 5
  • 38
  • 82
  • 1
    Enjoy or inspire from my Pulsar Library for Spring Boot in your next project: https://github.com/majusko/pulsar-java-spring-boot-starter – Mário Kapusta Aug 13 '20 at 17:13

1 Answers1

4

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.

vvra
  • 2,832
  • 5
  • 38
  • 82