【问题标题】:Stream support for local dynamodb?流对本地 dynamodb 的支持?
【发布时间】:2016-01-19 17:22:24
【问题描述】:

我似乎无法在本地 dynamo db 中获得流支持,它们是否受支持?我能找到的唯一迹象是the developer guide regarding local differences 中的最后一个要点:

如果您使用的是 DynamoDB Streams,则创建分片的速率可能会有所不同。在 DynamoDB Web 服务中,分片创建行为部分受表分区活动的影响。当您在本地运行 DynamoDB 时,没有表分区。在任何一种情况下,分片都是短暂的,因此您的应用程序不应依赖于分片行为。

在本地使用 dynamodb 时,似乎忽略了 StreamSpecification,因此在调用 createTable 或 describeTable 时没有 LatestStreamArn

以下代码返回带有托管 dynamodb 服务的 LatestStreamArn,但不返回本地 dynamodb:

ddb.createTable({
  TableName: 'streaming_test',

  AttributeDefinitions: [
    { AttributeName: 'id', AttributeType: 'S' }
  ],

  KeySchema: [
    { AttributeName: 'id', KeyType: 'HASH' }
  ],

  ProvisionedThroughput: {
    ReadCapacityUnits: 5,
    WriteCapacityUnits: 5
  },

  StreamSpecification: {
    StreamEnabled: true,
    StreamViewType: 'NEW_AND_OLD_IMAGES'
  }
}, function (err, data) {
  if (err) {
    console.log(err, err.stack)
  } else {
    // data.TableDescription.StreamSpecification and 
    // data.TableDescription.LatestStreamArn are undefined 
    // for dynamodb local
    console.log(data)
  }
})

【问题讨论】:

    标签: amazon-web-services amazon-dynamodb amazon-dynamodb-streams dynamo-local


    【解决方案1】:

    我无法重现您的问题。我采取的步骤:

    1. here 下载 DynamoDB Local
    2. 使用 java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -inMemory -sharedDb 在本地启动 DynamoDB
    3. 导航到http://localhost:8000/shell/
    4. 粘贴下面的代码并点击播放按钮。我写的和你上面的代码的唯一区别是我用dynamodb替换了ddb

    当我这样做时,我得到了一个非空且非空的 arn:aws:dynamodb:ddblocal:000000000000:table/streaming_test/stream/2017-02-12T08:39:03.722LatestStreamArn。

    dynamodb.createTable({
      TableName: 'streaming_test',
    
      AttributeDefinitions: [
        { AttributeName: 'id', AttributeType: 'S' }
      ],
    
      KeySchema: [
        { AttributeName: 'id', KeyType: 'HASH' }
      ],
    
      ProvisionedThroughput: {
        ReadCapacityUnits: 5,
        WriteCapacityUnits: 5
      },
    
      StreamSpecification: {
        StreamEnabled: true,
        StreamViewType: 'NEW_AND_OLD_IMAGES'
      }
    }, function (err, data) {
      if (err) {
        console.log(err, err.stack)
      } else {
        // data.TableDescription.StreamSpecification and 
        // data.TableDescription.LatestStreamArn are undefined 
        // for dynamodb local
        console.log(data)
      }
    })
    

    【讨论】:

    • 我无法确认这是否有效,但从赞成票来看,这对很多其他用户都有帮助。公认!谢谢
    • 我在本地发电机上遇到了同样的问题,但我使用的是现有的本地表,创建时没有流规范。当我重新创建本地表时,它没有问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多