1

Log4NetログをLogTableというSimpleDBテーブル/ドメインに書き込むアペンダーを作成しました。私は今、このテーブルから古いレコードを削除するWindowsサービスを書き込もうとしています。AmazonSimpleDBクライアントは確実に作成されており、手動で実行するとクエリはレコードを返します。ただし、コードが単体テストで実行された場合、結果は返されません。テーブル名と列名の大文字と小文字の区別は正しいです。

using (AmazonSimpleDB simpleDbClient = AWSClientFactory.CreateAmazonSimpleDBClient(accessKey, secretKey))
                {
                    String selectExpression = String.Format("select * from LogTable where Timestamp < '{0:o}'", purgeDate);
                    SelectRequest selectRequestAction = new SelectRequest().WithSelectExpression(selectExpression);
                    SelectResponse selectResponse = simpleDbClient.Select(selectRequestAction);

                    if (selectResponse.IsSetSelectResult())
                    {
                        BatchDeleteAttributesRequest deleteRequest = new BatchDeleteAttributesRequest().WithDomainName("LogTable");
                        deleteRequest.Item = new List<DeleteableItem>();

                        SelectResult selectResult = selectResponse.SelectResult;
                        foreach (Item item in selectResult.Item)
                        {
                            deleteRequest.Item.Add(new DeleteableItem { ItemName = item.Name });
                        }

                        if (deleteRequest.Item.Count > 0)
                        {
                            simpleDbClient.BatchDeleteAttributes(deleteRequest);
                        }

                        logger.InfoFormat("Success - {0} log records deleted from LogTable", deleteRequest.Item.Count);
                    }
}

これについての助けを本当にいただければ幸いです。

4

1 に答える 1

0

式を満たすレコードのみが返されるため、クエリが正しいことを確認してください。単純なselectクエリは何を返しますか?これを試して確認してください-

select * from LogTable  

ヒットがない場合は、リージョンのエンドポイントを指定してください。

それが戻った場合は、指定した条件が一致していることを確認してください。

編集済み:

このコードを実行し、ドメインが属するこのリンクを使用してリージョンエンドポイントを指定してみてください。

AmazonSimpleDBConfig theConfig = new AmazonSimpleDBConfig();
theConfig.ServiceURL = myEndpoint;  //where myEndPoint is the region endpoint you are interested in
AmazonSimpleDBClient simpleDbClient= new AmazonSimpleDBClient(myKey, mySecretKey, theConfig);
String selectExpression = "select * from LogTable";
SelectRequest selectRequestAction = new SelectRequest();
selectRequestAction.SelectExpression = selectExpression;
selectRequestAction.NextToken = null;
SelectResponse selectResponse = simpleDbClient.Select(selectRequestAction);
SelectResult selectResult = selectResponse.SelectResult;
List<Item> itemList = selectResult.Item;
于 2013-01-22T06:56:09.297 に答える