Search code examples
javaillegalstateexceptionchroniclechronicle-queue

Java chronicle throwing IllegalStateExecption at high number of messages


When the number of messages to write are high, getting IllegalStateException after some time. Here is the code:

    chronicle = ChronicleQueueBuilder.indexed(basePrefix).build();

loop begin

    {
      appender = chronicle.createAppender();
      appender.startExcerpt();
      appender.writeObject(message);
      appender.finish();
    }

loop end

    chronicle.close();

java chronicle 3.6.2 is the version with java 1.7.


Solution

  • The most common reason for this error in Indexed Chronicle was that it was a single threaded writer. You need to ensure you only have one thread writing to this, possibly with locking if needed.

    You should be able to create just one Appender, ever and lock on this object or the queue itself (if you are using multiple threads)

    Chronicle Queue v4+ doesn't have this limitation and supports any number of threads with a single file per cycle.