0

RMQConsumer in my code is a spring bean which is initialised at the time of Spring container initialisation. It starts listening to RMQ messages on the queue as soon that Spring bean is ready irrespective of the whole Spring container is ready or not. I want to start the consumption of messages only when the kubernates pod status is 1/1. As during rolling deployment, old pods are not terminated unless new pods are 1/1 status, which causes almost double the amount of pod count and spikes the consumption rate which is not desired in my case of some reasons.

What i tried I removed the channel.basicConsume method of RMq api which was executed at Bean postConstruct. And added the code in a Rest controller method under endpoint ‘’’/postStart’’’ which i configured in kubernates deployment file under lifecycle hook of postStart, which doesnt seems to work. The hook is called before spring application even prints its first log(verified with time stamps).

vinit
  • 41
  • 6
  • Could you provide your Deployment manifests? –  Dec 22 '21 at 08:59
  • Cant share the whole file due to organisation policies. Sharing relevant snippet: lifecycle: postStart: httpGet: path: /postStart port:8080. Let me know if you need anything specific – vinit Dec 22 '21 at 11:51
  • Have you set `readinessProbe` for your Spring deployment? – mdobrucki Dec 23 '21 at 09:34

1 Answers1

0

Can you check if readinessProbe will help in this use case.

Please refer below article which can help.

Promoting Liveness and Readiness as core Spring Boot concepts https://spring.io/blog/2020/03/25/liveness-and-readiness-probes-with-spring-boot

sridhar
  • 223
  • 2
  • 8