'RabbitMQ best practice: long timespans without connection

I have a set of distributed devices that transmit messages to a server backend via RabbitMQ. For the devices, it cannot be guaranteed that there is a persistent Internet connection, in fact there might be days or weeks without a connection. The problem is that there might also be power loss during that time. Some of the messages, cannot get lost. My current approach is as follows:

In any situation where I need to send something to RabbitMQ, I append it to a SQLite database table. A second thread gets notified whenever there is an addition and then fetches the data from the database and sends it to RabbitMQ as soon as there is an active connection. A similar solution was also suggested here.

To me, this seems like an Anti-Pattern, but I could not think of any other reasonable solution. What would be the correct way to approach this situation? The distributed devices run Windows, so using a dedicated software solution for local caching would be possible at least in terms of resource availability.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source