Container for the parameters to the GetRecords operation. Gets data records from an Amazon Kinesis stream's shard.

Specify a shard iterator using the ShardIterator parameter. The shard iterator specifies the position in the shard from which you want to start reading data records sequentially. If there are no records available in the portion of the shard that the iterator points to, GetRecords returns an empty list. Note that it might take multiple calls to get to a portion of the shard that contains records.

You can scale by provisioning multiple shards per stream while considering service limits (for more information, see Streams Limits in the Amazon Kinesis Streams Developer Guide). Your application should have one thread per shard, each reading continuously from its stream. To read from a stream continually, call GetRecords in a loop. Use GetShardIterator to get the shard iterator to specify in the first GetRecords call. GetRecords returns a new shard iterator in NextShardIterator. Specify the shard iterator returned in NextShardIterator in subsequent calls to GetRecords. Note that if the shard has been closed, the shard iterator can't return more data and GetRecords returns null in NextShardIterator. You can terminate the loop when the shard is closed, or when the shard iterator reaches the record with the sequence number or other attribute that marks it as the last record to process.

Each data record can be up to 1 MB in size, and each shard can read up to 2 MB per second. You can ensure that your calls don't exceed the maximum supported size or throughput by using the Limit parameter to specify the maximum number of records that GetRecords can return. Consider your average record size when determining this limit.

The size of the data returned by GetRecords varies depending on the utilization of the shard. The maximum size of data that GetRecords can return is 10 MB. If a call returns this amount of data, subsequent calls made within the next 5 seconds throw ProvisionedThroughputExceededException. If there is insufficient provisioned throughput on the shard, subsequent calls made within the next 1 second throw ProvisionedThroughputExceededException. Note that GetRecords won't return any data when it throws an exception. For this reason, we recommend that you wait one second between calls to GetRecords; however, it's possible that the application will get exceptions for longer than 1 second.

To detect whether the application is falling behind in processing, you can use the MillisBehindLatest response attribute. You can also monitor the stream using CloudWatch metrics and other mechanisms (see Monitoring in the Amazon Kinesis Streams Developer Guide).

Each Amazon Kinesis record includes a value, ApproximateArrivalTimestamp, that is set when a stream successfully receives and stores a record. This is commonly referred to as a server-side timestamp, whereas a client-side timestamp is set when a data producer creates or sends the record to a stream (a data producer is any data source putting data records into a stream, for example with PutRecords). The timestamp has millisecond precision. There are no guarantees about the timestamp accuracy, or that the timestamp is always increasing. For example, records in a shard or across a stream might have timestamps that are out of order.

상속: AmazonKinesisRequest
		GetRecordsResponse GetRecords (AmazonKinesisClient client, string shardId)
		{
			var siRequest = new GetShardIteratorRequest ();
			siRequest.ShardId = shardId;
			siRequest.StreamName = "Test1";
			siRequest.ShardIteratorType = "TRIM_HORIZON";

			var siResponse = client.GetShardIterator (siRequest);
			var request = new GetRecordsRequest ();
			request.ShardIterator = siResponse.ShardIterator;

			return client.GetRecords (request);
		}
예제 #2
0
        /// <summary>
        /// <para>This operation returns one or more data records from a shard. A <c>GetRecords</c> operation request can retrieve up to 10 MB of
        /// data.</para> <para>You specify a shard iterator for the shard that you want to read data from in the <c>ShardIterator</c> parameter. The
        /// shard iterator specifies the position in the shard from which you want to start reading data records sequentially. A shard iterator
        /// specifies this position using the sequence number of a data record in the shard. For more information about the shard iterator, see
        /// GetShardIterator.</para> <para> <c>GetRecords</c> may return a partial result if the response size limit is exceeded. You will get an error,
        /// but not a partial result if the shard's provisioned throughput is exceeded, the shard iterator has expired, or an internal processing
        /// failure has occurred. Clients can request a smaller amount of data by specifying a maximum number of returned records using the <c>Limit</c>
        /// parameter. The <c>Limit</c> parameter can be set to an integer value of up to 10,000. If you set the value to an integer greater than
        /// 10,000, you will receive <c>InvalidArgumentException</c> .</para> <para>A new shard iterator is returned by every <c>GetRecords</c> request
        /// in <c>NextShardIterator</c> ,
        /// which you use in the <c>ShardIterator</c> parameter of the next <c>GetRecords</c> request. When you repeatedly read from an
        /// Amazon Kinesis stream use a GetShardIterator request to get the first shard iterator to use in your first <c>GetRecords</c> request and then
        /// use the shard iterator returned in <c>NextShardIterator</c> for subsequent reads.</para> <para> <c>GetRecords</c> can return <c>null</c> for
        /// the <c>NextShardIterator</c> to reflect that the shard has been closed and that the requested shard iterator would never have returned more
        /// data. </para> <para>If no items can be processed because of insufficient provisioned throughput on the shard involved in the request,
        /// <c>GetRecords</c> throws <c>ProvisionedThroughputExceededException</c> .</para>
        /// </summary>
        /// 
        /// <param name="getRecordsRequest">Container for the necessary parameters to execute the GetRecords service method on AmazonKinesis.</param>
        /// 
        /// <returns>The response from the GetRecords service method, as returned by AmazonKinesis.</returns>
        /// 
        /// <exception cref="T:Amazon.Kinesis.Model.ProvisionedThroughputExceededException" />
        /// <exception cref="T:Amazon.Kinesis.Model.ExpiredIteratorException" />
        /// <exception cref="T:Amazon.Kinesis.Model.InvalidArgumentException" />
        /// <exception cref="T:Amazon.Kinesis.Model.ResourceNotFoundException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<GetRecordsResponse> GetRecordsAsync(GetRecordsRequest getRecordsRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetRecordsRequestMarshaller();
            var unmarshaller = GetRecordsResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, GetRecordsRequest, GetRecordsResponse>(getRecordsRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
예제 #3
0
		internal GetRecordsResponse GetRecords(GetRecordsRequest request)
        {
            var task = GetRecordsAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
예제 #4
0
        /// <summary>
        /// Initiates the asynchronous execution of the GetRecords operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetRecords operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<GetRecordsResponse> GetRecordsAsync(GetRecordsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetRecordsRequestMarshaller();
            var unmarshaller = GetRecordsResponseUnmarshaller.Instance;

            return InvokeAsync<GetRecordsRequest,GetRecordsResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the GetRecords operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetRecords operation on AmazonKinesisClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetRecords
        ///         operation.</returns>
        public IAsyncResult BeginGetRecords(GetRecordsRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new GetRecordsRequestMarshaller();
            var unmarshaller = GetRecordsResponseUnmarshaller.Instance;

            return BeginInvoke<GetRecordsRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
예제 #6
0
        internal GetRecordsResponse GetRecords(GetRecordsRequest request)
        {
            var marshaller = new GetRecordsRequestMarshaller();
            var unmarshaller = GetRecordsResponseUnmarshaller.Instance;

            return Invoke<GetRecordsRequest,GetRecordsResponse>(request, marshaller, unmarshaller);
        }
        /// <summary>
        /// <para>This operation returns one or more data records from a shard. A <c>GetRecords</c> operation request can retrieve up to 10 MB of
        /// data.</para> <para>You specify a shard iterator for the shard that you want to read data from in the <c>ShardIterator</c> parameter. The
        /// shard iterator specifies the position in the shard from which you want to start reading data records sequentially. A shard iterator
        /// specifies this position using the sequence number of a data record in the shard. For more information about the shard iterator, see
        /// GetShardIterator.</para> <para> <c>GetRecords</c> may return a partial result if the response size limit is exceeded. You will get an error,
        /// but not a partial result if the shard's provisioned throughput is exceeded, the shard iterator has expired, or an internal processing
        /// failure has occurred. Clients can request a smaller amount of data by specifying a maximum number of returned records using the <c>Limit</c>
        /// parameter. The <c>Limit</c> parameter can be set to an integer value of up to 10,000. If you set the value to an integer greater than
        /// 10,000, you will receive <c>InvalidArgumentException</c> .</para> <para>A new shard iterator is returned by every <c>GetRecords</c> request
        /// in <c>NextShardIterator</c> ,
        /// which you use in the <c>ShardIterator</c> parameter of the next <c>GetRecords</c> request. When you repeatedly read from an
        /// Amazon Kinesis stream use a GetShardIterator request to get the first shard iterator to use in your first <c>GetRecords</c> request and then
        /// use the shard iterator returned in <c>NextShardIterator</c> for subsequent reads.</para> <para> <c>GetRecords</c> can return <c>null</c> for
        /// the <c>NextShardIterator</c> to reflect that the shard has been closed and that the requested shard iterator would never have returned more
        /// data. </para> <para>If no items can be processed because of insufficient provisioned throughput on the shard involved in the request,
        /// <c>GetRecords</c> throws <c>ProvisionedThroughputExceededException</c> .</para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetRecords service method on AmazonKinesis.</param>
        /// 
        /// <returns>The response from the GetRecords service method, as returned by AmazonKinesis.</returns>
        /// 
        /// <exception cref="T:Amazon.Kinesis.Model.ProvisionedThroughputExceededException" />
        /// <exception cref="T:Amazon.Kinesis.Model.ExpiredIteratorException" />
        /// <exception cref="T:Amazon.Kinesis.Model.InvalidArgumentException" />
        /// <exception cref="T:Amazon.Kinesis.Model.ResourceNotFoundException" />
		public GetRecordsResponse GetRecords(GetRecordsRequest request)
        {
            var task = GetRecordsAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
예제 #8
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetRecords operation.
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the GetRecords operation on AmazonKinesisClient.</param>
 /// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
 /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 public void GetRecordsAsync(GetRecordsRequest request, AmazonServiceCallback<GetRecordsRequest, GetRecordsResponse> callback, AsyncOptions options = null)
 {
     options = options == null?new AsyncOptions():options;
     var marshaller = new GetRecordsRequestMarshaller();
     var unmarshaller = GetRecordsResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<GetRecordsRequest,GetRecordsResponse> responseObject 
                     = new AmazonServiceResult<GetRecordsRequest,GetRecordsResponse>((GetRecordsRequest)req, (GetRecordsResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<GetRecordsRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }
예제 #9
0
 IAsyncResult invokeGetRecords(GetRecordsRequest getRecordsRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new GetRecordsRequestMarshaller().Marshall(getRecordsRequest);
     var unmarshaller = GetRecordsResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
예제 #10
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetRecords operation.
 /// <seealso cref="Amazon.Kinesis.IAmazonKinesis.GetRecords"/>
 /// </summary>
 /// 
 /// <param name="getRecordsRequest">Container for the necessary parameters to execute the GetRecords operation on AmazonKinesis.</param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// 
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetRecords
 ///         operation.</returns>
 public IAsyncResult BeginGetRecords(GetRecordsRequest getRecordsRequest, AsyncCallback callback, object state)
 {
     return invokeGetRecords(getRecordsRequest, callback, state, false);
 }
예제 #11
0
 /// <summary>
 /// <para>This operation returns one or more data records from a shard. A <c>GetRecords</c> operation request can retrieve up to 10 MB of
 /// data.</para> <para>You specify a shard iterator for the shard that you want to read data from in the <c>ShardIterator</c> parameter. The
 /// shard iterator specifies the position in the shard from which you want to start reading data records sequentially. A shard iterator
 /// specifies this position using the sequence number of a data record in the shard. For more information about the shard iterator, see
 /// GetShardIterator.</para> <para> <c>GetRecords</c> may return a partial result if the response size limit is exceeded. You will get an error,
 /// but not a partial result if the shard's provisioned throughput is exceeded, the shard iterator has expired, or an internal processing
 /// failure has occurred. Clients can request a smaller amount of data by specifying a maximum number of returned records using the <c>Limit</c>
 /// parameter. The <c>Limit</c> parameter can be set to an integer value of up to 10,000. If you set the value to an integer greater than
 /// 10,000, you will receive <c>InvalidArgumentException</c> .</para> <para>A new shard iterator is returned by every <c>GetRecords</c> request
 /// in <c>NextShardIterator</c> ,
 /// which you use in the <c>ShardIterator</c> parameter of the next <c>GetRecords</c> request. When you repeatedly read from an
 /// Amazon Kinesis stream use a GetShardIterator request to get the first shard iterator to use in your first <c>GetRecords</c> request and then
 /// use the shard iterator returned in <c>NextShardIterator</c> for subsequent reads.</para> <para> <c>GetRecords</c> can return <c>null</c> for
 /// the <c>NextShardIterator</c> to reflect that the shard has been closed and that the requested shard iterator would never have returned more
 /// data. </para> <para>If no items can be processed because of insufficient provisioned throughput on the shard involved in the request,
 /// <c>GetRecords</c> throws <c>ProvisionedThroughputExceededException</c> .</para>
 /// </summary>
 /// 
 /// <param name="getRecordsRequest">Container for the necessary parameters to execute the GetRecords service method on AmazonKinesis.</param>
 /// 
 /// <returns>The response from the GetRecords service method, as returned by AmazonKinesis.</returns>
 /// 
 /// <exception cref="ProvisionedThroughputExceededException"/>
 /// <exception cref="ExpiredIteratorException"/>
 /// <exception cref="InvalidArgumentException"/>
 /// <exception cref="ResourceNotFoundException"/>
 public GetRecordsResponse GetRecords(GetRecordsRequest getRecordsRequest)
 {
     IAsyncResult asyncResult = invokeGetRecords(getRecordsRequest, null, null, true);
     return EndGetRecords(asyncResult);
 }