4

I am planning to use chronicle 4 (SingleChronicleQueue) for IPC .

I was using chronicle 3 previous (IndexedQueue ) and it was not thread safe and I used to create multiple queues per thread but i was told by some one by using SingleChronicleQueue i can use 1 queue for all threads in a JVM .

But does it stand good if 2 different processes are trying to write concurrently in same chronicle queue would it be safe ?

Is this recommended to do or for different processes I need to create different queues.

user3887600
  • 138
  • 1
  • 8

1 Answers1

5

Thank you for the question about Chronicle Software products.

The relevant link in the documentation is: https://github.com/OpenHFT/Chronicle-Queue#single-chronicle-queue

The key phrase being: "concurrent writers on the same machine".

Chronicle-Queue uses compare-and-swap operations to atomically mutate the shared off-heap memory that backs a queue instance, so multiple processes can write, and read to/from a queue on the same machine.

I hope this answers your question.

Best Regards, Terry

  • 1
    IMPORTANT: I want to add that an ExcerptAppender or ExcerptTailer should not be shared between threads. – Terry Williams Aug 24 '17 at 12:01
  • 1
    do you mean that ExcerptAppender & ExcerptTailer are not thread safe.? – Devas Aug 29 '17 at 05:26
  • Hi Krishas.That is correct, these objects are not safe for access from multiple threads. – Terry Williams Aug 29 '17 at 12:57
  • 2
    The documentation gives pointers on how to write to[1], and read from[2] a queue. Calling acquireAppender() on the queue will return a thread-local ExcerptAppender, which can be re-used *within* the same thread. This method is fairly cheap though, so we would recommend just calling acquireAppender() whenever you need to write to the queue. Calling createTailer() on the queue will return a new instance of an ExcerptTailer. Again, this can be re-used *within* the same thread, but should not be handed to other threads. – Terry Williams Aug 29 '17 at 12:57
  • 1
    1) https://github.com/OpenHFT/Chronicle-Queue#writing-to-a-queue 2) https://github.com/OpenHFT/Chronicle-Queue#reading-from-a-queue – Terry Williams Aug 29 '17 at 12:57
  • 1
    Well covered +1 – Peter Lawrey Sep 05 '17 at 23:14
  • 1
    Thanks Terry. Well explained. +1 – Devas Sep 11 '17 at 06:58
  • Hi Terry, so I tried to create one appender for each thread and when I do that, I got exception: java.nio.BufferOverflowException, Caused by java.nio.channels.OverlappingFileLockException Does it only work for certain file system? – Theboy May 04 '18 at 14:59