我有一些情况下,我需要与体发送消息:
""
当我尝试使用下面的代码要做到:
var sqsClient= new AmazonSQSClient(new BasicAWSCredentials("accessKeyId","SecretKey"), new AmazonSQSConfig()
{
ServiceURL ="https://sqs.eu-west-1.amazonaws.com/"
});
//obj value is "" and provided from user
var result = sqsClient.SendMessageAsync("queueURL", obj.ToString()).Result;
我得到:
{Amazon.SQS.AmazonSQSException:请求必须包含参数消息体。 ---> Amazon.Runtime.Internal.HttpErrorResponseException:类型Amazon.Runtime.Internal.HttpErrorResponseException'引发的异常。在Amazon.Runtime.HttpWebRequestMessage.d__20.MoveNext()中E:\ JenkinsWorkspaces \ V3-投石机释放\ AWSDotNetPublic \ SDK \ SRC \核心\ Amazon.Runtime \管道\ HttpHandler_mobile \ HttpRequestMessageFactory.cs:线539 ---完从先前的位置堆栈跟踪,其中引发异常---在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(工作任务)在Amazon.Runtime.Internal.HttpHandler
1.<InvokeAsync>d__9
1.MoveNext(中)在E:\ JenkinsWorkspaces \ v3的投石机释放\ AWSDotNetPublic \ SDK的\ src \核心\ Amazon.Runtime \管道\的HttpHandler \ HttpHandler.cs:行175 ---从先前的位置堆栈跟踪的结束,其中异常被抛出 - - 在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(工作任务)在Amazon.Runtime.Internal.Unmarshaller.d__31.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.SQS.Internal.ValidationResponseHandler.<InvokeAsync>d__1
1.MoveNext()---堆栈跟踪结束从以前的位置其中的例外是在电子商务抛出---在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(工作任务)在Amazon.Runtime.Internal.ErrorHandler.d__51.MoveNext()
1.MoveNext(): \ JenkinsWorkspaces \ V3-投石机释放\ AWSDotNetPublic \ SDK \ SRC \核心\ Amazon.Runtime \管道\的ErrorHandler \ ErrorHandler.cs:线104 ---从先前位置栈跟踪,其中引发异常的末尾在系统.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(工作任务)在Amazon.Runtime.Internal.CallbackHandler.d__9
--- End of inner exception stack trace --- at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleException(IExecutionContext executionContext, HttpErrorResponseException exception) in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\ErrorHandler\HttpErrorResponseExceptionHandler.cs:line 60 at Amazon.Runtime.Internal.ErrorHandler.ProcessException(IExecutionContext executionContext, Exception exception) in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\ErrorHandler\ErrorHandler.cs:line 212 at Amazon.Runtime.Internal.ErrorHandler.<InvokeAsync>d__51.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.Runtime.Internal.EndpointDiscoveryHandler.<InvokeAsync>d__2
1.MoveNext()---从以前的位置,其中异常堆栈跟踪的结尾在电子商务被扔在--- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()在Amazon.Runtime.Internal.EndpointDiscoveryHandler.d__21.MoveNext() in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\EndpointDiscoveryHandler.cs:line 79 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.Runtime.Internal.CredentialsRetriever.<InvokeAsync>d__7
1.MoveNext():\ JenkinsWorkspaces \ v3的投石机释放\ AWSDotNetPublic \ SDK的\ src \心病È\ Amazon.Runtime \管道\处理程序\ CredentialsRetriever.cs:管线98 ---从先前位置栈跟踪其中抛出异常---在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()在System.Runtime结束。 CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务task)在Amazon.Runtime.Internal.RetryHandler.d__101.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Amazon.Runtime.Internal.RetryHandler.<InvokeAsync>d__10
1.MoveNext()在E:\ JenkinsWorkspaces \ v3的投石机释放\ AWSDotNetPublic \ SDK的\ src \核心\ Amazon.Runtime \管道\ RetryHandler \ RetryHandler.cs:153行---从先前的位置堆栈跟踪,其中引发异常---在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(工作任务)结束在Amazon.Runtime.Internal.CallbackHandler.d__91.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9
1.MoveNext()---从以前的位置,其中的例外是在System.Runtime.CompilerServices抛出---在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()堆栈跟踪的结尾。 Ť askAwaiter.HandleNonSuccessAndDebuggerNotification(任务task)在Amazon.Runtime.Internal.ErrorCallbackHandler.d__51.MoveNext() in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\ErrorCallbackHandler.cs:line 58 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.Runtime.Internal.MetricsHandler.<InvokeAsync>d__1
1.MoveNext()}
但是发送:
" "
效果很好!
是否有任何workarrounds只发送
""
你说你正在尝试设置身体""
但你实际上做的是身体设置两个"
间的0字节空字符串。字符串文字实际上并不包含它周围的报价。如果空字符串是你真的想送什么,是不是在SQS有效。
邮件正文不能为空或空。
但是,如果你确实想发送的ASCII码为0x22 "
引号字符两个字节,这些都需要出现,你的字符串字面内部escaped。
var result = sqsClient.SendMessageAsync("queueURL", "\"\"").Result;
(注意,从SQS开发人员指南中引用来自于与消息atttibutes主要关注的网页,但它指的是实际的消息体,而不是信息的属性,其内容被称为Value
,不是“体”,并且是也如不支持空或无效单独提及。)