Java LedgerAPI - LedgerConfigurationService.getLedgerConfiguration() never finishes

Hey everyone, me again,

Just having some issues with the LedgerConfigurationService. I’m trying to get the deduplication time of the ledger as below:

  public void getLedgerConfiguration() {
    try {
      Flowable<LedgerConfigurationServiceOuterClass.LedgerConfiguration> configuration;
      // Assume that ledgerConfigurationClient is already initialized using `damlLedgerClient.getLedgerConifigurationClient()
      configuration = ledgerConfigurationClient.getLedgerConfiguration();
      configuration.blockingForEach(
          con -> {
            LOGGER.info("LedgerConfiguration is {}", con);
          });
      LOGGER.info("Finished GetLedgerConfig");
    } catch (Exception ex) {
      LOGGER.error("Error returning ledger configuration {}", ex.getMessage());
    }
  }

Now, I’m simply logging the ledgerConfiguration, which works fine as below:

16:00:19.907 [main] INFO  c.a.d.i.t.u.s.LedgerConfigurationService - LedgerConfiguration is max_deduplication_time {
  seconds: 86400
}

However, it stalls after this and never returns. Now I understand that in a blockingForEach, it only terminates when: Note: the method will only return if the upstream terminates or the current thread is interrupted.. However, it seems like in this case, the upstream should terminate after returning the max_deduplication_time, which is currently the only returned field in the LedgerConfigurationService. I have tested this on the Sandbox, the Sandbox with static time, and DAML on VMWare.

Let me know if this is a bug, or if I’ve done something wrong in my implementation.

Thank you!

1 Like

The LedgerConfigurationService is a streaming service. The docs state

LedgerConfigurationService allows clients to subscribe to changes of the ledger configuration.

Returns the latest configuration as the first response, and publishes configuration updates in the same stream.

So you shouldn’t expect it to terminate. If you just want the latest configuration, you’ll need to cancel the subscription after the first response.

2 Likes