3

1) In chronicle queue v4 most test patterns show some form of DocumentContext.isPresent() busy state checking, when ExcerptTailer is positioned at the end of the queue and code is waiting for new entries to arrive from ExcerptAppender.

2) Is there a built-in chronicle queue mechanism for asynchronous appender -> tailer notifications, such that upon receipt of a notification event, given tailer is guaranteed to have at least one entry posted by appender, ready for read?

3) If not, what is recommended pattern to implement such event listener? Please share a working example?

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
Andrei Pozolotin
  • 897
  • 3
  • 14
  • 21

1 Answers1

4

The recommended pattern for implementing a listener pattern is to use the methodReader/methodWriter which can also take care of timestamps when where you read was up.

I suggest you read these https://vanilla-java.github.io/tag/Microservices/ from the bottom up starting with Part 1.

For the tailer, the only way it know there is a message is by reading/polling the end of the queue. If the appender and tailer are in the same process you can use a different mechanism of your choice.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • A) re: **use the methodReader/methodWriter** - from [part-2](https://vanilla-java.github.io/2016/03/24/Microservices-in-the-Chronicle-world-Part-2.html) and [MethodReader.readOne()](https://github.com/OpenHFT/Chronicle-Wire/blob/master/src/main/java/net/openhft/chronicle/wire/MethodReader.java#L198) it seems that `readOne()` is semantically identical `isPresent()`, i.e. there no event notification or blocking going on, correct? – Andrei Pozolotin Jan 02 '17 at 20:19
  • B) re: **in the same process you can use a different mechanism** - in this case, what is `ExcerptAppender` / `ExcerptTailer` synchronization contract? i.e. is `appender...doc.close()` is a guarantee that `tailer...doc.isPresent()` will see the change, when notified after `appender...doc.close()`? – Andrei Pozolotin Jan 02 '17 at 20:26
  • @AndreiPozolotin correct. There is no blocking action. – Peter Lawrey Jan 02 '17 at 21:31
  • @AndreiPozolotin as soon as close is called the record is visible. – Peter Lawrey Jan 02 '17 at 21:32
  • @AndreiPozolotin you can use a Pauser on the Tailer and you can unparsed it on the appender for a low latency signal. – Peter Lawrey Jan 02 '17 at 21:32
  • @AndreiPozolotin I meant `unpause`, rather than `unparsed` ;) – Peter Lawrey Jan 03 '17 at 19:29