-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Jetstream / MessageConsumer not working in Kubernetes environment #6772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Seems like messages are not properly being acknowledged. When looking at:
You're getting redeliveries of messages and messages are not being acknowledged. Here the messages are being acknowledged:
Can you share any steps to reproduce? What does your message handling code look like, do you ack messages? |
Thanks for responding! Yes, as you can see in the information above when I run it outside Kubernetes, they are ack-ed. Couple more things to mention.
Code looks like this:
|
The consumer and stream sequence must NOT be compared. They are totally different. The stream sequence is the sequence in the stream and increases for every published message. The consumer sequence increases for every delivered message, including redeliveries. It's normal they are different and don't increase together. Should remove that bit of code that deletes the consumer based on that comparison. Am wondering whether |
Thank you, I'll remove that part. I was under the impression that consumer sequence must not be greater than stream sequence. Good point about TCSender.send(...), but for that reason, there's System.out.println(...) at the beginning of the method which isn't called (not mentioned in the logs, in case of Kubernetes deployment). Just to remind you... if I look at NATS consumer info (report), I'll see "Last Delivered Message Consumer Sequence" increasing, but "Stream Sequence" stays the same ... |
Does stream need to be created with "replicas=3" if I have a cluster of 3 replicas because I see that it's 1 by default? One additional information. If I change the consumer side to use NATS core, everything works flawlessly (same subject, same NATS cluster) in Kubernetes. Dunno if that helps. |
That is expected. The consumer sequence increases for every attempted delivery for your client. You are only getting redeliveries, looking at the max ack pending being reached and the redelivery count being increased as well. No new messages are delivered, only redelivered messages, so the highest delivered stream sequence remains the same. |
In that case you are not persisting data, though. |
What is different between your local setup and your Kubernetes setup? If you don't see any logs when deployed in Kubernetes, you might have some configuration differences, or different permissions? |
There should be no difference.
|
Also, note that I see the publisher app logs and it's sending messages to this subject echo.inbound.01591b40-1a79-4073-9a3f-3e84f017f31e using NAT core publish (not jetstream publish). |
Hi everyone, I'm experiencing the same issue when running under Docker. The NATS Streamer crashes with the following exception:
As a test, I installed the same Java version on the host machine. When I run the application directly on Ubuntu, everything works fine — but inside the Docker container, it fails with the error above. Any ideas what might be causing this? Thanks in advance! |
@Tauebenuss, could you perhaps setup a small reproducible example? Something like a small app that publishes into a stream and subscribing, that works on one environment, but doesn't on the other? |
Can you show the output of Regarding publishing with nats core to a stream, you should not do that generally speaking. |
Observed behavior
We're using a simplified API with MessageConsumer, following the example on GitHub. However, the consumer app is not working correctly when deployed in the Kubernetes. The app connects to the NATS and reads the stream and consumer information. The message consumer handler is not called even though LastDeliveredMessage-ConsumeSequence keeps increasing, but StreamSequence stays the same. I can restart the consumer application multiple times outside Kubernetes and the consumer will continue successfully. We're not sure how can this be related to Kubernetes, but that's the only difference in setup.
The consumer is durable, with the following settings:
Consumer report when consumer is deployed on Kubernetes:
Consumer report after consumer has been stopped on Kubernetes and started outside:
Expected behavior
MessageConsumer handler should receive messages as it does outside the Kubernetes env.
Server and client version
nats-server 2.10.26
nats.java 2.20.1
Host environment
No response
Steps to reproduce
No response
The text was updated successfully, but these errors were encountered: