【发布时间】:2013-07-04 18:26:47
【问题描述】:
在我的 asp.net Web 应用程序中,我使用 amazon 插件加载带有相应 isbn.in 代码的书籍图像,我将该图像转换为字节数组以将其存储到数据库中。但问题是它有时会回来错误见图片
任何人都可以指定此错误的原因,并请建议我一些解决方案。在此先感谢。
【问题讨论】:
标签: asp.net amazon-web-services
在我的 asp.net Web 应用程序中,我使用 amazon 插件加载带有相应 isbn.in 代码的书籍图像,我将该图像转换为字节数组以将其存储到数据库中。但问题是它有时会回来错误见图片
任何人都可以指定此错误的原因,并请建议我一些解决方案。在此先感谢。
【问题讨论】:
标签: asp.net amazon-web-services
当您达到油门限制时会发生这种情况。
尝试将您的代码包装在 try catch 块中
例如。
void withretry(string query)
{
ListMatchingProductsRequest request = new ListMatchingProductsRequest();
request.SellerId = amazonsetting.merchantId;
request.MarketplaceId = amazonsetting.marketplaceId;
request.QueryContextId = "Books";
request.Query = query;
try
{
ListMatchingProductsResponse response = amazonsetting.service.ListMatchingProducts(request);
if (response.IsSetListMatchingProductsResult())
{
ListMatchingProductsResult listMatchingProductsResult = response.ListMatchingProductsResult;
if (listMatchingProductsResult.IsSetProducts())
{
ProductList products = listMatchingProductsResult.Products;
List<Product> productList = products.Product;
Product product = productList[0];
if (product.IsSetIdentifiers())
{
IdentifierType identifiers = product.Identifiers;
if (identifiers.IsSetMarketplaceASIN())
{
ASINIdentifier marketplaceASIN = identifiers.MarketplaceASIN;
if (marketplaceASIN.IsSetMarketplaceId())
{
}
if (marketplaceASIN.IsSetASIN())
{
asin = marketplaceASIN.ASIN;
}
}
}
if (product.IsSetAttributeSets())
{
foreach (var attribute in product.AttributeSets.Any)
{
msg += ProductsUtil.FormatXml((System.Xml.XmlElement)attribute);
}
}
}
parsemsg();
}
}
catch (Exception ex)
{
string type = ex.Message;
if (type=="Request is throttled")
{
if (cnt<=maxretry)
{
cnt++;
withretry(query);
}
}
}
}
这将继续重试,直到达到 maxretry。
【讨论】: