TBD
Click Tag to Display Pages: development

TimeBase allows clients to subscribe to live data based on types, streams and symbols (entities) attributes, and change their subscription at any time.

There are three possible scenarios:

Basic

Subscription starts at some point of time (close to real-time) when the command reaches the server.

This scenario may be applied in case precise subscription timing and order is not critical.


// change entity entity
cursor.removeEntity(new ConstantIdentityKey("CLX20"));
cursor.addEntity(new ConstantIdentityKey("CLZ20"));
// add descriptor
cursor.addTypes("epam.timebase.samples.SensorType1");
// add stream
TickStream stream = Arrays.stream(tickDB.listStreams())
    .filter(item -> "SmartMetersOhio".equals(item.getKey()))
    .findFirst()
    .orElseThrow(() -> new IllegalStateException("Stream was not found"));
cursor.addStream(stream);

Precise Subscription Timing

This scenario may be applied in case it is critical to set the precise timing of a new subscription.

In this case, the subscribed data arrives precisely at the specified time but there is no guarantee as for the data ordering.


// specify time for newly subscribed data
cursor.setTimeForNewSubscriptions(Instant.now().toEpochMilli());
cursor.addEntity(new ConstantIdentityKey("TrafficLight-4419"));

Complete Reset

This scenario may be applied in case precise subscription timing and order are required.

It is slowest case due to the complete reset of all buffers.

Reset is performed at a specified time, starting from which you will receive data with the precise time and order.


// reset cursor
cursor.clearAllEntities();
String[] symbolsToAdd = new String[] {"Meter-1", "Meter-2", "Meter-3"};
cursor.addEntities(
    Arrays.stream(symbolsToAdd)
        .map(item -> new ConstantIdentityKey(item))
        .toArray(IdentityKey[]::new), 0, symbolsToAdd.length);
cursor.reset(Instant.parse("2020-08-04T10:12:35Z").toEpochMilli());