spring-cloud-aws Spring创建SQS不支持的消息头属性 [英] spring-cloud-aws Spring creates message header attribute not supported by SQS

查看:1750
本文介绍了spring-cloud-aws Spring创建SQS不支持的消息头属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Spring Cloud AWS消息传递,使用SQS发送/接收消息。

I'm using Spring Cloud AWS messaging to send/receive messages using SQS.

我的代码如下所示:

@SpringBootApplication
@Import(MessagingConfig.class)
public class App {
    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }
}


@Configuration
public class MessagingConfig {

    @Bean
    public QueueMessagingTemplate queueMessagingTemplate(AmazonSQS amazonSqs, ResourceIdResolver resourceIdResolver) {
        return new QueueMessagingTemplate(amazonSqs, resourceIdResolver);
    }

}

发件人代码如下通过控制器连接):

The sender code is like this (wired via a controller):

@Component
public class Sender {

    @Autowired
    private QueueMessagingTemplate queueMessagingTemplate;

    public void send(MyMessage message) {
        queueMessagingTemplate.convertAndSend("testQueue", message);
    }
}

我有一个申请。 yaml 文件,用于定义似乎正确加载的AWS参数。所以,当我运行这个应用程序,我得到以下警告/错误:

I have an application.yaml file that defines the AWS parameters that seem to be correctly loaded. So, when I run this application, I get the following warning/error:

Message header with name 'id' and type 'java.util.UUID' cannot be sent as message attribute because it is not supported by SQS.

我在这里做错了,或者Spring创建的方式有问题SQS的邮件?

Is there something that I'm doing wrong here, or is there an issue with the way Spring creates messages for SQS?

推荐答案

这似乎只是一个警告,不会影响邮件的发送和/或接收。当我测试这个对一个真正的SQS队列,我可以发送和接收消息。

This appears to be only a warning and does not affect the sending and/or receiving of the message. When I tested this against a real SQS queue, I could both send and receive messages.

然而,当在我的本地框使用elasticMQ作为真正的SQS的替代,它无法处理消息。它看起来像这个工具而不是Spring的问题。

However, when using elasticMQ on my local box as a replacement for the real SQS, it was failing to process the message. It looks like an issue with that tool rather than Spring.

这篇关于spring-cloud-aws Spring创建SQS不支持的消息头属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆