如何在消息中添加 MessageGroupId 参数?
How to add MessageGroupId parameter to message?
我正在尝试使用 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.access0(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开始,您需要在header或属性
中设置JMSXGroupID
JMSXGroupID (required for FIFO queues, not allowed for standard queues)
此外,请查看 key terms,您可能还需要一个 de-duplication ID。
我正在尝试使用 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.access0(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开始,您需要在header或属性
中设置JMSXGroupID
JMSXGroupID (required for FIFO queues, not allowed for standard queues)
此外,请查看 key terms,您可能还需要一个 de-duplication ID。