use of software.amazon.awssdk.services.kinesis.model.PutRecordRequest in project aws-doc-sdk-examples by awsdocs.
the class StockTradesWriter method sendStockTrade.
private static void sendStockTrade(StockTrade trade, KinesisClient kinesisClient, String streamName) {
byte[] bytes = trade.toJsonAsBytes();
// The bytes could be null if there is an issue with the JSON serialization by the Jackson JSON library.
if (bytes == null) {
System.out.println("Could not get JSON bytes for stock trade");
return;
}
System.out.println("Putting trade: " + trade.toString());
PutRecordRequest request = PutRecordRequest.builder().partitionKey(// We use the ticker symbol as the partition key, explained in the Supplemental Information section below.
trade.getTickerSymbol()).streamName(streamName).data(SdkBytes.fromByteArray(bytes)).build();
try {
kinesisClient.putRecord(request);
} catch (KinesisException e) {
e.getMessage();
}
}
Aggregations