Search in sources :

Example 1 with PutRecordResponse

use of software.amazon.awssdk.services.firehose.model.PutRecordResponse in project aws-doc-sdk-examples by awsdocs.

the class PutRecord method putSingleRecord.

// snippet-start:[firehose.java2.put_record.main]
public static void putSingleRecord(FirehoseClient firehoseClient, String textValue, String streamName) {
    try {
        SdkBytes sdkBytes = SdkBytes.fromByteArray(textValue.getBytes());
        Record record = Record.builder().data(sdkBytes).build();
        PutRecordRequest recordRequest = PutRecordRequest.builder().deliveryStreamName(streamName).record(record).build();
        PutRecordResponse recordResponse = firehoseClient.putRecord(recordRequest);
        System.out.println("The record ID is " + recordResponse.recordId());
    } catch (FirehoseException e) {
        System.out.println(e.getLocalizedMessage());
        System.exit(1);
    }
}
Also used : SdkBytes(software.amazon.awssdk.core.SdkBytes) PutRecordResponse(software.amazon.awssdk.services.firehose.model.PutRecordResponse) PutRecordRequest(software.amazon.awssdk.services.firehose.model.PutRecordRequest) FirehoseException(software.amazon.awssdk.services.firehose.model.FirehoseException) Record(software.amazon.awssdk.services.firehose.model.Record)

Aggregations

SdkBytes (software.amazon.awssdk.core.SdkBytes)1 FirehoseException (software.amazon.awssdk.services.firehose.model.FirehoseException)1 PutRecordRequest (software.amazon.awssdk.services.firehose.model.PutRecordRequest)1 PutRecordResponse (software.amazon.awssdk.services.firehose.model.PutRecordResponse)1 Record (software.amazon.awssdk.services.firehose.model.Record)1