1

i am working with ServiceStack.Aws and i am getting an ResourceNotFoundException, but i can't see the resource name that it looking for. ¿The resource name are sent in the exception? ¿How can i get it?

My model class is (table and index name exists)

[DynamoDBTable("SOME-TABLE-NAME")]
    public class Company
    {
        [DynamoDBHashKey]
        public string CompanyId { get; set; }

        [DynamoDBGlobalSecondaryIndexHashKey("SOME-INDEX-NAME")]
        public string ShortName { get; set; }

        public string DocumentNumber { get; set; }
        public string FullName { get; set; }
        public string Address { get; set; }
        public DateTime CreatedAt { get; set; }
    }

My code is

var awsDb = new AmazonDynamoDBClient();
            var db = new PocoDynamo(awsDb);

            db.RegisterTable<Company>();
            try
            {
                db.PutItem<Company>(new Company
                {
                    Address = "Some address #some number",
                    CompanyId = Guid.NewGuid().ToString(),
                    CreatedAt = DateTime.Now,
                    DocumentNumber = "11.222.333-4",
                    FullName = "Some company name",
                    ShortName = "ShortName"
                });
            }
            catch (ResourceNotFoundException ex)
            {

            }
            catch (Exception ex)
            {

            }

In my app.config i have (path and profile name exists. Region is ok too)

<aws region="us-east-1" profileName="profile-name" profilesLocation="some-path\certificados.txt">
  </aws>

Edit: The problem is that ServiceStack don't use AWS Attributes. So, i change DynamoDBTable to Alias and all work fine

4

1 回答 1

1

ServiceStack.Aws 的 PocoDynamo在幕后自动重试临时异常,因此可能已重试原始 AWS 异常。我刚刚ExceptionFilter此提交中添加了一个,它可以让您检查 AWS DynamoDB 客户端抛出的每个异常:

var dynamo = new PocoDynamo(awsDynamoClient) { 
    ExceptionFilter = ex => ex.Message.Print();
};

ExceptionFilter 从 v4.0.61 开始可用,现在可以在 MyGet 上使用

属性在 PocoDynamo 中也[DynamoDBGlobalSecondaryIndexHashKey]没有影响,请参阅有关使用 PocoDynamo 创建全局索引的文档。

于 2016-06-22T17:59:35.147 回答