I ran into the same problem with my systems that you see with a disconnected connection during very long tasks.
Perhaps a heartbeat can help keep your connection alive if your network setup is such that idle TCP / IP connections are greatly removed. If this is not the case, a change in heart rate will not help.
Changing the connection timeout will not help at all. This parameter is used only during the initial connection creation.
I use the manufacturer RabbitMQ to send long-term tasks (30 minutes +) to the consumer. The problem is that the consumer is still working on the task when the connection to the server is closed and an unconfirmed task is requested.
There are two reasons for this: both of them are already running:
- Connections fall randomly, even in the best of circumstances.
- Re-starting the process due to a message with a re-queue can cause problems.
By deploying RabbitMQ code with tasks that range from less than a second to several hours in time, I found that instant message confirmation and system updates with status messages are best suited for very long tasks, for example.
You will need a recording system (possibly with a database) that tracks the status of a given job.
When the consumer takes the message and starts the process, he must immediately acknowledge the message and send a message about the status of the "start" in the recording system.
At the end of the process, send another message to say this.
This will not solve the problem with a disconnected connection, but nothing will solve it 100%. Instead, it will prevent re-posting problems when the connection is deleted.
This solution really introduces another problem: when the process of long work falls, how do you resume work?
The main answer is to use the status of the recording system (your database) for the job, to inform you that you need to pick up this work again. When the application starts, check the database to make sure there is incomplete work. If so, resume or restart that work in any way suitable.
Derick bailey
source share