Beispiel #1
0
  private static void put_record(AmazonKinesis client, int current_index) {
    PutRecordRequest putRecord = new PutRecordRequest();
    putRecord.setStreamName(Constant.STREAM_NAME);
    putRecord.setPartitionKey(get_partition_key(current_index));
    putRecord.setExplicitHashKey(get_explicit_key(current_index));
    putRecord.setData(ByteBuffer.wrap((current_index + "").getBytes()));

    try {
      PutRecordResult pr = client.putRecord(putRecord);
      System.out.println("put record : " + current_index + "  shard id: " + pr.getShardId());
    } catch (AmazonClientException ex) {
      LOG.warn("Error sending record to Amazon Kinesis.", ex);
    }
  }
 /**
  * The hash value used to explicitly determine the shard the data record is assigned to by
  * overriding the partition key hash.
  *
  * @param explicitHashKey The hash value used to explicitly determine the shard the data record is
  *     assigned to by overriding the partition key hash.
  * @return Returns a reference to this object so that method calls can be chained together.
  */
 public PutRecordRequest withExplicitHashKey(String explicitHashKey) {
   setExplicitHashKey(explicitHashKey);
   return this;
 }