我使用相当简单的本地堆栈设置来模拟从 AWS SQS 队列中的读取。当我运行此样板代码时,我收到有关缺少操作的错误。
Exception has occurred: CLR/Amazon.SQS.AmazonSQSException
An exception of type 'Amazon.SQS.AmazonSQSException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'MissingAction; see the SQS docs.'
我不太确定从这里该去哪里。我已经到处搜索这个错误,但我还没有找到任何东西。这是我的代码。
using Amazon;
using Amazon.Extensions.NETCore.Setup;
using Amazon.SQS;
using Amazon.SQS.Model;
using Microsoft.Extensions.DependencyInjection;
var awsCredentials = new Amazon.Runtime.BasicAWSCredentials("key", "secret");
var services = new ServiceCollection();
services.AddAWSService<IAmazonSQS>(new AWSOptions {
DefaultClientConfig =
{
ServiceURL = "http://localhost:4576",
UseHttp = true,
},
Credentials = awsCredentials,
Region = RegionEndpoint.USEast1
});
var provider = services.BuildServiceProvider();
var sqsClient = provider.GetRequiredService<IAmazonSQS>();
var response = await sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest{
QueueUrl="http://localhost:4576/000000000000/CustomerEventQueue",
MaxNumberOfMessages=10,
WaitTimeSeconds=2
// (Could also request attributes, set visibility timeout, etc.)
});
Console.ReadLine();
我刚刚遇到了完全相同的问题。看起来您的版本不兼容,请参阅github