public class PutRecordRequest extends AmazonWebServiceRequest implements Serializable
PutRecord operation
.
This operation puts a data record into an Amazon Kinesis stream from a producer. This operation must be called to send data from the producer into the
Amazon Kinesis stream for real-time ingestion and subsequent processing. The PutRecord
operation requires the name of the stream that
captures, stores, and transports the data; a partition key; and the data blob itself. The data blob could be a segment from a log file,
geographic/location data, website clickstream data, or any other data type.
The partition key is used to distribute data across shards. Amazon Kinesis segregates the data records that belong to a data stream into multiple shards, using the partition key associated with each data record to determine which shard a given data record belongs to.
Partition keys are Unicode strings, with a maximum length limit of 256 bytes. An MD5 hash function is used to map partition keys to 128-bit integer
values and to map associated data records to shards using the hash key ranges of the shards. You can override hashing the partition key to determine
the shard by explicitly specifying a hash value using the ExplicitHashKey
parameter. For more information, see the Amazon Kinesis Developer Guide .
PutRecord
returns the shard ID of where the data record was placed and the sequence number that was assigned to the data record.
The SequenceNumberForOrdering
sets the initial sequence number for the partition key. Later PutRecord
requests to the same
partition key (from the same client) will automatically increase from SequenceNumberForOrdering
, ensuring strict sequential ordering.
If a PutRecord
request cannot be processed because of insufficient provisioned throughput on the shard involved in the request,
PutRecord
throws ProvisionedThroughputExceededException
.
Data records are accessible for only 24 hours from the time that they are added to an Amazon Kinesis stream.
Constructor and Description |
---|
PutRecordRequest() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
ByteBuffer |
getData()
The data blob to put into the record, which must be Base64 encoded.
|
String |
getExplicitHashKey()
The hash value used to explicitly determine the shard the data record
is assigned to by overriding the partition key hash.
|
String |
getPartitionKey()
Determines which shard in the stream the data record is assigned to.
|
String |
getSequenceNumberForOrdering()
The sequence number to use as the initial number for the partition
key.
|
String |
getStreamName()
The name of the stream to put the data record into.
|
int |
hashCode() |
void |
setData(ByteBuffer data)
The data blob to put into the record, which must be Base64 encoded.
|
void |
setExplicitHashKey(String explicitHashKey)
The hash value used to explicitly determine the shard the data record
is assigned to by overriding the partition key hash.
|
void |
setPartitionKey(String partitionKey)
Determines which shard in the stream the data record is assigned to.
|
void |
setSequenceNumberForOrdering(String sequenceNumberForOrdering)
The sequence number to use as the initial number for the partition
key.
|
void |
setStreamName(String streamName)
The name of the stream to put the data record into.
|
String |
toString()
Returns a string representation of this object; useful for testing and
debugging.
|
PutRecordRequest |
withData(ByteBuffer data)
The data blob to put into the record, which must be Base64 encoded.
|
PutRecordRequest |
withExplicitHashKey(String explicitHashKey)
The hash value used to explicitly determine the shard the data record
is assigned to by overriding the partition key hash.
|
PutRecordRequest |
withPartitionKey(String partitionKey)
Determines which shard in the stream the data record is assigned to.
|
PutRecordRequest |
withSequenceNumberForOrdering(String sequenceNumberForOrdering)
The sequence number to use as the initial number for the partition
key.
|
PutRecordRequest |
withStreamName(String streamName)
The name of the stream to put the data record into.
|
copyPrivateRequestParameters, getRequestClientOptions, getRequestCredentials, getRequestMetricCollector, setRequestCredentials, setRequestMetricCollector, withRequestMetricCollector
public String getStreamName()
Constraints:
Length: 1 - 128
Pattern: [a-zA-Z0-9_.-]+
public void setStreamName(String streamName)
Constraints:
Length: 1 - 128
Pattern: [a-zA-Z0-9_.-]+
streamName
- The name of the stream to put the data record into.public PutRecordRequest withStreamName(String streamName)
Returns a reference to this object so that method calls can be chained together.
Constraints:
Length: 1 - 128
Pattern: [a-zA-Z0-9_.-]+
streamName
- The name of the stream to put the data record into.public ByteBuffer getData()
Constraints:
Length: 0 - 51200
public void setData(ByteBuffer data)
Constraints:
Length: 0 - 51200
data
- The data blob to put into the record, which must be Base64 encoded.
The maximum size of the data blob is 50 kilobytes (KB).public PutRecordRequest withData(ByteBuffer data)
Returns a reference to this object so that method calls can be chained together.
Constraints:
Length: 0 - 51200
data
- The data blob to put into the record, which must be Base64 encoded.
The maximum size of the data blob is 50 kilobytes (KB).public String getPartitionKey()
Constraints:
Length: 1 - 256
public void setPartitionKey(String partitionKey)
Constraints:
Length: 1 - 256
partitionKey
- Determines which shard in the stream the data record is assigned to.
Partition keys are Unicode strings with a maximum length limit of 256
bytes. Amazon Kinesis uses the partition key as input to a hash
function that maps the partition key and associated data to a specific
shard. Specifically, an MD5 hash function is used to map partition
keys to 128-bit integer values and to map associated data records to
shards. As a result of this hashing mechanism, all data records with
the same partition key will map to the same shard within the stream.public PutRecordRequest withPartitionKey(String partitionKey)
Returns a reference to this object so that method calls can be chained together.
Constraints:
Length: 1 - 256
partitionKey
- Determines which shard in the stream the data record is assigned to.
Partition keys are Unicode strings with a maximum length limit of 256
bytes. Amazon Kinesis uses the partition key as input to a hash
function that maps the partition key and associated data to a specific
shard. Specifically, an MD5 hash function is used to map partition
keys to 128-bit integer values and to map associated data records to
shards. As a result of this hashing mechanism, all data records with
the same partition key will map to the same shard within the stream.public String getExplicitHashKey()
Constraints:
Pattern: 0|([1-9]\d{0,38})
public void setExplicitHashKey(String explicitHashKey)
Constraints:
Pattern: 0|([1-9]\d{0,38})
explicitHashKey
- The hash value used to explicitly determine the shard the data record
is assigned to by overriding the partition key hash.public PutRecordRequest withExplicitHashKey(String explicitHashKey)
Returns a reference to this object so that method calls can be chained together.
Constraints:
Pattern: 0|([1-9]\d{0,38})
explicitHashKey
- The hash value used to explicitly determine the shard the data record
is assigned to by overriding the partition key hash.public String getSequenceNumberForOrdering()
PutRecord
from the same client
and for the same partition key will increase from the
SequenceNumberForOrdering
value.
Constraints:
Pattern: 0|([1-9]\d{0,128})
PutRecord
from the same client
and for the same partition key will increase from the
SequenceNumberForOrdering
value.public void setSequenceNumberForOrdering(String sequenceNumberForOrdering)
PutRecord
from the same client
and for the same partition key will increase from the
SequenceNumberForOrdering
value.
Constraints:
Pattern: 0|([1-9]\d{0,128})
sequenceNumberForOrdering
- The sequence number to use as the initial number for the partition
key. Subsequent calls to PutRecord
from the same client
and for the same partition key will increase from the
SequenceNumberForOrdering
value.public PutRecordRequest withSequenceNumberForOrdering(String sequenceNumberForOrdering)
PutRecord
from the same client
and for the same partition key will increase from the
SequenceNumberForOrdering
value.
Returns a reference to this object so that method calls can be chained together.
Constraints:
Pattern: 0|([1-9]\d{0,128})
sequenceNumberForOrdering
- The sequence number to use as the initial number for the partition
key. Subsequent calls to PutRecord
from the same client
and for the same partition key will increase from the
SequenceNumberForOrdering
value.public String toString()
toString
in class Object
Object.toString()
Copyright © 2013 Amazon Web Services, Inc. All Rights Reserved.