Gateway Bridge offline store messages in folder


We are currently trying to use the gateway bridge to get the gateway to store messages in the Queue when there is no internet connection (QoS=1), but we would also like that these messages could remain in the queue even if the service/gateway is restarted.

Currently the messages are stored on Ram memory, so we had to change this by setting the storage to use the FileStore which is already implemented in the paho library:

In the interlan/integration/mqtt/backend.go:128

// Test setting a message store by string
f := paho.NewFileStore("/opt/BridgeMsgStore")

This does indeed work, and messages are stored in the BridgeMsgStore folder, each packet not ACK’d is saved in plain format (either Json or protobuf) with name o.1.msg, with increasing number.

However, the problem comes when the service/gateway is restarted but there is still no internet connection. In this case, the bridge doesn’t keep appending messages to the previous ones, therefore all messages from this moment on are lost and not stored.
When internet is back again, just the messages that are stored in the BridgeMsgStore folder are sent to the server. So any message received after the service is restarted but when there is still no internet connection are lost.

Also, is there any way to get the DEBUG prints from the paho library? I have enabled the DEBUG flag of the bridge service, but I can’t seem to get any DEBUG line from the Paho library. I’m unfamiliar with the Golang language and I can’t seem to find how to do this.

Has anybody tried anything similar? Or could somebody shed some light on the issue?
Thank you for your time.