Aws-sdk-android: Callback for `KinesisFirehoseRecorder`

Created on 22 Nov 2020  路  2Comments  路  Source: aws-amplify/aws-sdk-android

After run submitAllRecords, there is no feedback on whether it sent the information, or what information was sent.

saveRecord has a limitation of information, so how do we know whether it truncates the information or not?

From docs:

Requests that are successfully sent will be deleted from the device. Requests that fail due to the device being offline will stop the submission process and be kept.

However, I cannot know whether it faced another error or not? Or how much information is stored on the device?

Kinesis Usage Question closing-soon-if-no-response

Most helpful comment

However, I cannot know whether it faced another error or not?

Hi @amadeu01, submitAllRecords is a synchronous operation, so if it completes without throwing, then it was successful. You can do something like this:

new AsyncTask<Void, Void>() {
    @Override
    protected Void doInBackground(Void... v) {
        try {
            firehoseRecorder.submitAllRecords();
            Log.d("MyApp", "submitAllRecords succeeded");
        } catch (AmazonClientException ace) {
            Log.e("MyApp", "submitAllRecords failed", ace);
        }
    }
}.execute();

Or how much information is stored on the device?

We don't have an explicit API for doing this, but you could probably figure out how much data is in cache like this:

int fileSizeInBytes = new File(directoryUsedToConstructKinesisFirehoseRecorder, "kinesis_firehose_records").length();

The file name ("kinesis_firehose_records") is an internal implementation detail though, so keep in mind it could change in future versions of the SDK.

All 2 comments

However, I cannot know whether it faced another error or not?

Hi @amadeu01, submitAllRecords is a synchronous operation, so if it completes without throwing, then it was successful. You can do something like this:

new AsyncTask<Void, Void>() {
    @Override
    protected Void doInBackground(Void... v) {
        try {
            firehoseRecorder.submitAllRecords();
            Log.d("MyApp", "submitAllRecords succeeded");
        } catch (AmazonClientException ace) {
            Log.e("MyApp", "submitAllRecords failed", ace);
        }
    }
}.execute();

Or how much information is stored on the device?

We don't have an explicit API for doing this, but you could probably figure out how much data is in cache like this:

int fileSizeInBytes = new File(directoryUsedToConstructKinesisFirehoseRecorder, "kinesis_firehose_records").length();

The file name ("kinesis_firehose_records") is an internal implementation detail though, so keep in mind it could change in future versions of the SDK.

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

Was this page helpful?
0 / 5 - 0 ratings