I want to use Chronicle Queues as inboxes for user messages, with each user of my application having his own queue. However, I'm facing the following "issues":
Since the number of messages per user is not that high, all messages for a single user could be stored in a single queue file without cycling. How can I disable cycling?
In case it is possible to disable cycling, can the whole queue be stored in a single file instead of a directory containing a single queue file plus the directory-listing.cq4t ?
On my Linux OS with EXT4 filesystem, an empty queue uses 83.9Mb of disk space. Can this be reduced to only take roughly the size of the content?
In case one or more of the given issues cannot be circumvented, is there another way to realize user inboxes with Chronicle Queues, like sub-queues or something else?
To reduce the size of the files, you can reduce the blockSize
used by the queue:
try (final SingleChronicleQueue queue = SingleChronicleQueueBuilder.binary(tmpDir.newFolder()).
blockSize(4096).
build()) {
You could store the mailbox name as part of each event:
try (final DocumentContext documentContext =
queue.acquireAppender().writingDocument()) {
documentContext.wire().getValueOut().
text("user@mailbox").writeText(email);
}
Finally, if you really want to disable the cycle behaviour, you could supply the queue with a clock that never advances:
final AtomicLong fixedClock = new AtomicLong(System.currentTimeMillis());
try (final SingleChronicleQueue queue = SingleChronicleQueueBuilder.binary(tmpDir.newFolder()).
timeProvider(fixedClock::get).
blockSize(4096).
build()) {
Note that this mode of operation is not a supported use-case.
The directory-listing file is required by the internal mechanics of the queue, so there is no way of using the queue without it.
Ensure that you carry out testing when changing any of these configuration parameters.