Skip to main content

TickCursor API

Reading Messages

TickCursor API allows reading messages from streams.

Cursors consume messages one by one in exactly the same chronological order as they have been written by Loaders.


You can create cursors on the TickDb and a TickStream level using select() or executeQuery().

  • Pass data selection options as SelectionOptions().
  • Use operation to increment the current cursor position to the next message.
  • getMessage() is used with every and returns the message the cursor is pointing to.
  • Call cursor.close() once reading is completed.
Create a new cursor to read all types of messages from the beginning of the stream.
SelectionOptions options = new SelectionOptions();
try (TickCursor cursor =, options))
// Iterate cursor and get messages
while ( {
InstrumentMessage message = cursor.getMessage();
System.out.println("Read message: " + message.toString());
messages.add(new InstrumentMessage().copyFrom(message));

Make sure to use getMessage() data prior the following operation or copy the returned message using copyFrom() method of an InstrumentMessage() function.


Refer to code samples to view more reading examples.

Reverse Reading

As we have already mentioned, Cursors read messages in a chronological order. Nevertheless, you can read messages in the reversed order by adding reversed selection option.

Add selection option Reversed
options.reversed = true;

Live Reading operation returns false as soon as you have reached the end of the stream and/or there are no more messages to read. Hence, you can make wait for new messages to come. Cursors that do that are called live cursors. Add live selection option when creating a cursor to activate a live cursor.

Add selection option Live = true;
// do select ...
while ( { // next() will wait for new messages

Real-Time Notifications

Use realTimeNotification flag in selection options to enable/disable notifications when you transition from reading historical data to live-reading mode.

When live cursor is used to read stream from some time in the past (bootstrap with historical data) there is an option to get notified when live cursor is done reading historical data and switched to live data. With this option cursor will give you special RealtimeStartedMessage that marks end of historical data. 

To enable this feature set SelectionOption.realTimeNotification flag (default is false)

Add selection option realTimeNotification
options.realTimeNotification = false;

Reading Out-of-Order Late Messages

TimeBase cursors receive historical messages in a strictly chronological order. In live-mode reading scenarios, it is possible that newly-arrived messages have timestamps in the time range that has already been read. allowLateOutOfOrder flag in selection options allows receiving such messages even if they are out of order with respect to the current reading time.

Add selection option allowLateOutOfOrder
options.allowLateOutOfOrder = false;

Messages with timestamps prior to cursor's select time or last reset time will not be delivered even with allowLateOutOfOrder enabled.

Reading Raw Messages

Cursors can read raw messages or bound to native classes. Use raw selection option to read unbound messages.

Add selection option Raw
options.raw = true;

Refer to Data Encoding for more information about encoding and decoding messages.


Cursors can read messages based on a specific subscription. Basic subscription can be created using select() when creating a cursor.

try (TickCursor cursor =, new SelectionOptions(), types, identities)) { 
    // read data

Subscriptions can be modified on the fly - refer to Dynamic Subscription Change for more information.

Reading from Unique Streams

You can get a cached unique stream snapshot by adding the following options:

  • options.rebroadcast - use to rebroadcast unique message on open/reset cursors.
  • options.allowLateOutOfOrder - refer to the late messages section.
options.rebroadcast = true;  
options.allowLateOutOfOrder = true;

Refer to Stream to learn more about unique streams.

Reading from Spaces

In selection options you can set a specific space to read from. If set then data only from the specified space will be loaded. If set to {@code null} then data from all spaces is loaded. Any non-null value is permitted only for streams that supports spaces.

Populate selection option to read from a Space = "mySpace";
  • Refer to Data Distribution for more information about working with spaces.
  • Refer to TickLoader API for more information about writing into spaces.
  • Refer to How To to learn more about spaces and how to work with them.