Accedi ai record negli stream CDC in Amazon Keyspaces - Amazon Keyspaces (per Apache Cassandra)

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Accedi ai record negli stream CDC in Amazon Keyspaces

Per accedere ai record di uno stream, utilizzi l'API Amazon Keyspaces Streams. La sezione seguente contiene esempi su come accedere ai record utilizzando. AWS CLI

Per le autorizzazioni richieste, consulta Configura le autorizzazioni per lavorare con i flussi CDC in Amazon Keyspaces.

Accedere ai record di uno stream utilizzando il AWS CLI
  1. Puoi utilizzare l'API Amazon Keyspaces Streams per accedere ai record delle modifiche dello stream. Per ulteriori informazioni, consulta Amazon Keyspaces Streams API Reference. Per recuperare gli shard all'interno dello stream, puoi utilizzare l'get-streamAPI come mostrato nell'esempio seguente.

    aws keyspacesstreams get-stream \ --stream-arn 'arn:aws:cassandra:aws-region:111122223333:/keyspace/mykeyspace/table/mytable/stream/STREAM_LABEL'

    Di seguito è riportato un esempio di output.

    { "StreamArn": "arn:aws:cassandra:aws-region:111122223333:/keyspace/mykeyspace/table/mytable/stream/2023-05-11T21:21:33.291", "StreamStatus": "ENABLED", "StreamViewType": "NEW_AND_OLD_IMAGES", "CreationRequestDateTime": "<CREATION_TIME>", "KeyspaceName": "mykeyspace", "TableName": "mytable", "StreamLabel": "2023-05-11T21:21:33.291", "Shards": [ { "SequenceNumberRange": { "EndingSequenceNumber": "<END_SEQUENCE_NUMBER>", "StartingSequenceNumber": "<START_SEQUENCE_NUMBER>" }, "ShardId": "<SHARD_ID>" }, ] }
  2. Per recuperare i record dallo stream, iniziate con un iteratore che vi fornisca il punto di partenza per l'accesso ai record. A tale scopo, puoi utilizzare gli shard all'interno del flusso CDC restituito dall'API nel passaggio precedente. Per raccogliere l'iteratore, puoi utilizzare l'API. get-shard-iterator Per questo esempio, si utilizza un iteratore di tipo TRIM_HORIZON che recupera dall'ultimo punto (o inizio) tagliato dello shard.

    aws keyspacesstreams get-shard-iterator \ --stream-arn 'arn:aws:cassandra:aws-region:111122223333:/keyspace/mykeyspace/table/mytable/stream/STREAM_LABEL' \ --shard-id 'SHARD_ID' \ --shard-iterator-type 'TRIM_HORIZON'

    L'output del comando è simile a quello dell'esempio seguente.

    { "ShardIterator": "<SHARD_ITERATOR>" }
  3. Per recuperare i record CDC utilizzando l'get-recordsAPI, puoi utilizzare l'iteratore restituito nell'ultimo passaggio. Il comando seguente ne è un esempio.

    aws keyspacesstreams get-records \ --shard-iterator 'SHARD_ITERATOR' \ --limit 100