作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 JmsTemplate
将消息发送到 AwsSQS fifo 队列.
代码:
Message message = new Message().withBody("Hi");
jmsTemplate.convertAndSend(message);
当我运行上面的代码时,我收到错误
Caused by: com.amazonaws.services.sqs.model.AmazonSQSException: The request must contain the parameter MessageGroupId. (Service: AmazonSQS; Status Code: 400; Error Code: MissingParameter; Request ID: 94f6257b-0f2e-5e3d-9469-7c1066d45816; Proxy: null)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1819) ~[aws-java-sdk-core-1.12.24.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleServiceErrorResponse(AmazonHttpClient.java:1403) ~[aws-java-sdk-core-1.12.24.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1372) ~[aws-java-sdk-core-1.12.24.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1145) ~[aws-java-sdk-core-1.12.24.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:802) ~[aws-java-sdk-core-1.12.24.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:770) ~[aws-java-sdk-core-1.12.24.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:744) ~[aws-java-sdk-core-1.12.24.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:704) ~[aws-java-sdk-core-1.12.24.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:686) ~[aws-java-sdk-core-1.12.24.jar:na]
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:550) ~[aws-java-sdk-core-1.12.24.jar:na]
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:530) ~[aws-java-sdk-core-1.12.24.jar:na]
at com.amazonaws.services.sqs.AmazonSQSClient.doInvoke(AmazonSQSClient.java:2271) ~[aws-java-sdk-sqs-1.12.24.jar:na]
at com.amazonaws.services.sqs.AmazonSQSClient.invoke(AmazonSQSClient.java:2238) ~[aws-java-sdk-sqs-1.12.24.jar:na]
at com.amazonaws.services.sqs.AmazonSQSClient.invoke(AmazonSQSClient.java:2227) ~[aws-java-sdk-sqs-1.12.24.jar:na]
at com.amazonaws.services.sqs.AmazonSQSClient.executeSendMessage(AmazonSQSClient.java:1817) ~[aws-java-sdk-sqs-1.12.24.jar:na]
at com.amazonaws.services.sqs.AmazonSQSClient.sendMessage(AmazonSQSClient.java:1786) ~[aws-java-sdk-sqs-1.12.24.jar:na]
at com.amazon.sqs.javamessaging.AmazonSQSMessagingClientWrapper.sendMessage(AmazonSQSMessagingClientWrapper.java:202) ~[amazon-sqs-java-messaging-lib-1.0.8.jar:na]
... 16 common frames omitted
我试过添加
MessageGroupId
像这样,但这也不起作用
Message message = new Message().withBody("Hi")
.withAttributes(Map.of("MessageGroupId", "1"));
jmsTemplate.convertAndSend(message);
有没有其他方法可以使用
JmsTemplate
将消息发送到 SQS fifo 队列?
最佳答案
来自 aws documentation ,您需要设置JMSXGroupID
在标题或属性中
JMSXGroupID (required for FIFO queues, not allowed for standard queues)
关于java - 如何将 MessageGroupId 参数添加到消息中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68408192/
我是一名优秀的程序员,十分优秀!