protected static void putRecordIntoDeliveryStream ( ) throws IOException { try ( InputStream inputStream = Thread . currentThread ( ) . getContextClassLoader ( ) . getResourceAsStream ( PUT_RECORD_STREAM_SOURCE ) ) { if ( inputStream == null ) { throw new FileNotFoundException ( "Could not find file " + PUT_RECORD_STREAM_SOURCE ) ; } try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( inputStream ) ) ) { String line = null ; while ( ( line = reader . readLine ( ) ) != null ) { PutRecordRequest putRecordRequest = new PutRecordRequest ( ) ; putRecordRequest . setDeliveryStreamName ( deliveryStreamName ) ; String data = line + "\n" ; Record record = createRecord ( data ) ; putRecordRequest . setRecord ( record ) ; // Put record into the DeliveryStream firehoseClient . putRecord ( putRecordRequest ) ; } } } }
Method to put records in the specified delivery stream by reading contents from sample input file using PutRecord API .