TickLoader Interface Overview

Writing Messages

Use TickLoader API to write into TimeBase. TimeBase uses Loaders to add messages to streams. Use send() to send your messages to loader. Call loader.close() once writing is completed.

// provide LoadingOptions
LoadingOptions options = new LoadingOptions();
try (TickLoader<InstrumentMessage> loader = changeStream.createLoader(options)) {

Writing Raw Data

Loaders can write messages already bound to native classes or raw messages (unbound).

//write data in raw mode
options.raw = true;

Writing Modes

TimeBase can be seen as a chronologically arranged pieces of data. In relation to that, TimeBase offers several different data writing modes that can be set in LoadingOptions. writeMode when creating a new loader:

Only messages with timestamps that are newer than the last recorded message timestamp are written into a stream.

Default mode. Writes data into a stream and truncates all the existing messages after the timestamp of the first newly-recorded message.

Truncation removes all the data stored after the specific timestamp. In this writing mode a stream is truncated every time a loader writes messages before the timestamp of the last recorded message.

New data is inserted into a stream according to the timestamp chronological order without truncation. Refer to Data Distribution for more information.

Writing Into Spaces

In case you plan to work with data that is not chronologically arranged, you can create dedicated data partitions (spaces) to physically distribute TS files based on their time range or other criteria.

options.space = "mySpace";

Event Listener

Loaders write messages asynchronously. loader.send() will not therefore, tell whether a specific message has been recorded successfully or not. You can add an Event Listener to a loader to get (track) possible errors.

//adding event listener to loader example
loader.addEventListener((e) -> System.out.println(e.getMessage()));

Use addErrorAction() to set a behavior for specific error types:

  • NotifyAndAbort - through an exception in case of an error. Writing is aborted.
  • NotifyAndContinue - through an exception in case of an error. Writing continues. Default behavior.
  • Continue - Writing continues in case of en error.
options.addErrorAction(LoadingError.class, LoadingOptions.ErrorAction.NotifyAndAbort);
options.addErrorAction(OutOfSequenceMessageException.class, LoadingOptions.ErrorAction.NotifyAndContinue);
options.addErrorAction(SkipMessageException.class, LoadingOptions.ErrorAction.Continue);

To remove event listener:


Subscription Listener

Subscription listener notifies loaders about changes in cursors’ subscriptions on the specific stream loader is writing into.


On-Demand Data Flushing

In some rare cases, e.i. when data is written to a stream throughout an extensive time period, you can use loader.flush() to save all written data on disk. Data flushing is a sync operation.