Open bhavadeepk opened 6 years ago
This should work out of the box. What exception do you get when you try to load the queue after reboot?
When I use, in my onCreate() or BootUpReceiver,
File file = // ...
QueueFile queueFile = new QueueFile.Builder(file).build();
I end up with EOFException unless I perform file.delete()
operation.
I'm facing the same issue where I end up with an EOF exception unless I delete the underlying file. Is there a resolution here?
I'm seeing the same problem as well. My purpose for using this library is to persist data locally and read it back in after an unexpected shutdown, but I I just get EOFException when trying to access the existing file (even if it's zero bytes).
I think core issue for me is that the example is unclear as to what
// File...
represents. I took it to mean I'm responsible for creating the queue file and providing that to QueueFile
. This results in a 0-byte file ready for input. However, QueueFile(File)
assumes the file will always either not exist or already have the requisite header, which causes the EOFException.
I'd think QueueFile would check the length of available bytes in the stream before attempting to read in the header (and if length is 0 bytes, just create the header), but apparently not.
My solution was to ignore the reference in the example and just use:
QueueFile queueFile = new QueueFile.Builder(new File("fileThatWillBeCreatedIfNecessary.queue")).build();
If I have some time to dig deeper into the source I'll submit a PR.
I have the same problem. Is there a workaround?
From Javadocs,
I have some messages to be sent to a server from custom android devices in FIFO order. If the device is rebooted before all the messages in the queue are successfully sent, the remainder is persisted in the
File
I wrapped thequeueFile
with. But I cannot import this existing file into a new instance(after reboot) of the QueueFile unless I delete the file. #125 which loses the messages stacked before shutdown.How can I persist the queue across reboots using this library?
Let me know if you have any questions. Thanks