Skip to content

receive_queue_records

receive_queue_records(
    queue_arn: QueueARN,
    *,
    config_overrides: Optional[KinesisClientConfig] = None,
    limit: Optional[ReceiveQueueRecordsInputLimit] = None,
    wait_time_seconds: Optional[ReceiveQueueRecordsWaitTimeSeconds] = None,
    visibility_timeout_seconds: Optional[VisibilityTimeoutSeconds] = None,
) -> ReceiveQueueRecordsOutput

Receives up to 10 records from the specified queue. Each record is returned with a receipt handle, which is the identifier you use to acknowledge the record or change its visibility.

A record returned by ReceiveQueueRecords becomes in flight: it is not visible to any consumer instance for the duration of its visibility timeout, so subsequent receive requests do not return it while your queue consumer processes it. Acknowledge the record with AcknowledgeQueueRecords when you finish processing it. A record that is not acknowledged before its visibility timeout expires becomes visible in the queue again and can be received by any consumer instance.

Use WaitTimeSeconds to control how long the call waits for a record to become visible before returning. If a record becomes visible sooner, the call returns sooner. If the wait time expires and no records are visible, the call returns an empty list of records.

Records are not necessarily received in the order they were written to the data stream.

A queue delivers records while it is in the ACTIVE state.

On rare occasions, a queue can deliver a record more than once. Design your queue consumer to be idempotent, so that processing the same record more than once is safe.

Parameters:

  • queue_arn (QueueARN) –

    The ARN of the queue to receive records from.

  • limit (Optional[ReceiveQueueRecordsInputLimit], default: None ) –

    The maximum number of records to return. The queue never returns more records than this value, and might return fewer. The default is 10.

  • wait_time_seconds (Optional[ReceiveQueueRecordsWaitTimeSeconds], default: None ) –

    The duration, in seconds, that the call waits for a record to become visible before returning. The default is 9.

  • visibility_timeout_seconds (Optional[VisibilityTimeoutSeconds], default: None ) –

    The duration, in seconds, that the records returned by this request are in flight and not visible to any consumer instance. If you do not specify this value, the queue's visibility timeout is used.

Raises:

  • AccessDeniedException –

    Specifies that you do not have the permissions required to perform this operation.

  • InternalFailureException –

    The processing of the request failed because of an unknown error, exception, or failure.

  • InvalidArgumentException –

    A specified parameter exceeds its restrictions, is not supported, or can't be used. For more information, see the returned message.

  • KMSAccessDeniedException –

    The ciphertext references a key that doesn't exist or that you don't have access to.

  • KMSDisabledException –

    The request was rejected because the specified KMS key isn't enabled.

  • KMSInvalidStateException –

    The request was rejected because the state of the specified resource isn't valid for this request. For more information, see How Key State Affects Use of a Customer Master Key in the Amazon Web Services Key Management Service Developer Guide.

  • KMSNotFoundException –

    The request was rejected because the specified entity or resource can't be found.

  • KMSOptInRequired –

    The Amazon Web Services access key ID needs a subscription for the service.

  • KMSThrottlingException –

    The request was denied due to request throttling. For more information about throttling, see Limits in the Amazon Web Services Key Management Service Developer Guide.

  • ResourceNotFoundException –

    The requested resource could not be found. The stream might not be specified correctly.

  • ThrottlingException –

    The request was denied because the request rate is too high. Reduce the frequency of your requests, and retry them with exponential backoff.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_kinesis/_services/kinesis.py
def receive_queue_records(
    self,
    queue_arn: "capo_kinesis.types.queue_arn.QueueARN",
    *,
    config_overrides: Optional[KinesisClientConfig] = None,
    limit: Optional[
        "capo_kinesis.types.receive_queue_records_input_limit.ReceiveQueueRecordsInputLimit"
    ] = None,
    wait_time_seconds: Optional[
        "capo_kinesis.types.receive_queue_records_wait_time_seconds.ReceiveQueueRecordsWaitTimeSeconds"
    ] = None,
    visibility_timeout_seconds: Optional[
        "capo_kinesis.types.visibility_timeout_seconds.VisibilityTimeoutSeconds"
    ] = None,
) -> "capo_kinesis.types.receive_queue_records_output.ReceiveQueueRecordsOutput":
    """<p>Receives up to 10 records from the specified queue. Each record is returned with a receipt handle, which is the identifier you use to acknowledge the record or change its visibility.</p> <p>A record returned by <code>ReceiveQueueRecords</code> becomes in flight: it is not visible to any consumer instance for the duration of its visibility timeout, so subsequent receive requests do not return it while your queue consumer processes it. Acknowledge the record with <a>AcknowledgeQueueRecords</a> when you finish processing it. A record that is not acknowledged before its visibility timeout expires becomes visible in the queue again and can be received by any consumer instance.</p> <p>Use <code>WaitTimeSeconds</code> to control how long the call waits for a record to become visible before returning. If a record becomes visible sooner, the call returns sooner. If the wait time expires and no records are visible, the call returns an empty list of records.</p> <p>Records are not necessarily received in the order they were written to the data stream.</p> <p>A queue delivers records while it is in the <code>ACTIVE</code> state.</p> <p>On rare occasions, a queue can deliver a record more than once. Design your queue consumer to be idempotent, so that processing the same record more than once is safe.</p>

    Args:
        queue_arn: <p>The ARN of the queue to receive records from.</p>
        limit: <p>The maximum number of records to return. The queue never returns more records than this value, and might return fewer. The default is 10.</p>
        wait_time_seconds: <p>The duration, in seconds, that the call waits for a record to become visible before returning. The default is 9.</p>
        visibility_timeout_seconds: <p>The duration, in seconds, that the records returned by this request are in flight and not visible to any consumer instance. If you do not specify this value, the queue's visibility timeout is used.</p>

    Raises:
        capo_kinesis.errors.access_denied_exception.AccessDeniedException: <p>Specifies that you do not have the permissions required to perform this operation.</p>
        capo_kinesis.errors.internal_failure_exception.InternalFailureException: <p>The processing of the request failed because of an unknown error, exception, or failure.</p>
        capo_kinesis.errors.invalid_argument_exception.InvalidArgumentException: <p>A specified parameter exceeds its restrictions, is not supported, or can't be used. For more information, see the returned message.</p>
        capo_kinesis.errors.kms_access_denied_exception.KMSAccessDeniedException: <p>The ciphertext references a key that doesn't exist or that you don't have access to.</p>
        capo_kinesis.errors.kms_disabled_exception.KMSDisabledException: <p>The request was rejected because the specified KMS key isn't enabled.</p>
        capo_kinesis.errors.kms_invalid_state_exception.KMSInvalidStateException: <p>The request was rejected because the state of the specified resource isn't valid for this request. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/key-state.html">How Key State Affects Use of a Customer Master Key</a> in the <i>Amazon Web Services Key Management Service Developer Guide</i>.</p>
        capo_kinesis.errors.kms_not_found_exception.KMSNotFoundException: <p>The request was rejected because the specified entity or resource can't be found.</p>
        capo_kinesis.errors.kms_opt_in_required.KMSOptInRequired: <p>The Amazon Web Services access key ID needs a subscription for the service.</p>
        capo_kinesis.errors.kms_throttling_exception.KMSThrottlingException: <p>The request was denied due to request throttling. For more information about throttling, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/limits.html#requests-per-second">Limits</a> in the <i>Amazon Web Services Key Management Service Developer Guide</i>.</p>
        capo_kinesis.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource could not be found. The stream might not be specified correctly.</p>
        capo_kinesis.errors.throttling_exception.ThrottlingException: <p>The request was denied because the request rate is too high. Reduce the frequency of your requests, and retry them with exponential backoff.</p>
        capo_kinesis.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_kinesis.types.receive_queue_records_input.ReceiveQueueRecordsInput]",
    ) -> OperationResponse[
        "capo_kinesis.types.receive_queue_records_output.ReceiveQueueRecordsOutput"
    ]:
        import capo_kinesis._operations.kinesis_20131202.receive_queue_records

        output, http_response = (
            capo_kinesis._operations.kinesis_20131202.receive_queue_records.receive_queue_records(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ReceiveQueueRecords")
    )
    input_: capo_kinesis.types.receive_queue_records_input.ReceiveQueueRecordsInput = {
        "queue_arn": queue_arn
    }
    if limit is not None:
        input_["limit"] = limit
    if wait_time_seconds is not None:
        input_["wait_time_seconds"] = wait_time_seconds
    if visibility_timeout_seconds is not None:
        input_["visibility_timeout_seconds"] = visibility_timeout_seconds

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output