Skip to content

How to read errors from Aeron Archive replication operations

Problem

You want to understand the errors raised by Aeron Archive during a replication (AeronArchive.replicate) operation.

Solution

There are two options:

  • call AeronArchive.pollForErrorResponse(), which returns a string containing an error message, or null if no error
  • call AeronArchive.checkForErrorResponse(), which calls the AeronArchive.Context.errorHandler(ErrorHandler) if set, or throws an ArchiveException if not.

Sample

1
2
3
4
5
...
    final var replicationId = archive.replicate(0L, Aeron.NULL_VALUE,
        AeronArchive.CONTROL_STREAM_ID_DEFAULT, src.ControlChannel, null);
    final var errorMsg = archive.pollForErrorResponse();
...

Discussion

If needed, you can also use the RecordingSignalAdapter to follow progress.

See Also