Point in Time Recovery

Table of Contents

Point in time recovery is a way of ensuring data is not lost when connection to the Ledger Event Stream is lost. As a point of reference is required, recovery can only be performed from the second time the code is run onwards. 

Storing the Point in Time Recovery

To restore the data at a later point in time it is necessary to first store it.

To do so, the string myOffSet = tx.getOffset() can be utilised, as shown in the code snippet below. 

Sample Code
    public void processEgressChoice(TransactionTree tx) {
        String myOffSet = tx.getOffset();
		System.out.println("Offset for recovering for point in time is : " + myOffset);
        .filter(te -> te instanceof ExercisedEvent)
        .filter(te -> !((ExercisedEvent) te).isConsuming())
        .forEach(te -> {
            ExercisedEvent ee = (ExercisedEvent) te;
            String choice = ee.getChoice();
            Value value = ee.getChoiceArgument().asRecord().get().getFields().get(0).getValue();
            print(choice + "\n" + value.toString());

Recovering the Point in Time Recovery

To recover from a point in time it is necessary to take the last offset value from the logs. This is displayed as "My Offset: 106995". The value, in this example "106995", represented by myOffset in the code snippet below, is subsequently used within the LedgerOffset.Absolute() method.

ITE1 Update

The below code sample has been updated to include accessToken.

Sample Code
public void registerEgressChoiceCallback(DamlLedgerClient client, String partyId) {
        Flowable<TransactionTree> transactionsTrees = client.getTransactionsClient().getTransactionsTrees(
                new LedgerOffset.Absolute(myOffset),
                new FiltersByParty(Collections.singletonMap(partyId, NoFilter.instance)), true, accessToken);
        EgressChoiceConsumer egressChoiceConsumer = new EgressChoiceConsumer();
        transactionsTrees.subscribe(tx -> egressChoiceConsumer.processTransactionTree(tx),
                e -> {
                    print("Error in processTransactionTree! Cause: " + e.getCause() + "; Error message: " + e.getMessage());

Related Pages:

There are no related labels.

Browse Popular Pages:

No labels match these criteria.

This document provides general information only. ASX Limited (ABN 98 008 624 691) and its related bodies corporate (“ASX”) makes no representation or warranty with respect to the accuracy, reliability or completeness of the information. To the extent permitted by law, ASX and its employees, officers and contractors shall not be liable for any loss or damage arising in any way (including by way of negligence) from or in connection with any information provided or omitted or from anyone acting or refraining to act in reliance on this information.

© 2022 ASX Limited ABN 98 008 624 691