I have been working with Pika for some time, used it in multiple projects, but still unsure if I am doing things right.
I am almost always using python, thus Pika for publishing and never for consuming, therefore in short I need to send messages consistently and hopefully with as little errors as possible on the way. For this, is it better to use short lived connections or long lived?
Before hands, I was using the short lived approach:
Connect -> send -> close -> repeat for the each message
For some weird reasons I was getting a lot of warnings
"
2024-01-23 14:23:52.088532+00:00 [warning] <0.1048873.0> client unexpectedly closed TCP connection"
Also I was getting missed heartbeats, but I have no clue why, connections were short lived.
Now I decided to make long lived connection and I think I broke stuff in production environment -_-...
As a result I decided to rewrite the whole RMQ utilities, I followed the example of yours at
https://github.com/pika/pika/blob/main/examples/long_running_publisher.pyand have built the following.
I would really appreciate if you could identify the problems in my code and help me to design the well working version.
1. I initiate a single instance of RMQ per application or worker through django settings:
```
from project.utils.rmq_utils import RMQPublisher
# One connection per app for now
RMQPublisherInstance = RMQPublisher()
RMQPublisherInstance.start()
```
2. Here is the publisher
https://bitbucket.org/shecemenko/workspace/snippets/7qqBEjI decided to create snippet for it so that you could view all conveniently
Thank you sooo much!