使用 Spring 集成 + AWS SQS 序列化异常

Serializing exception using Spring Integration + AWS SQS

我正在尝试使用 Spring 与 Amazon SQS 的集成,但无法弄清楚我做错了什么。

如果我使用如下的内存队列,一切正常:

<channel id="businessEvents">
    <queue />
</channel>

但是当我将其更改为使用 AWS SQS 时,如下所示:

<int-sqs:channel id="businessEvents" 
    region-id="us-east-1"
    queue-name="events-sqs" 
    aws-credentials-provider="awsCredentialsProvider"  />

我收到以下错误:

org.springframework.integration.MessagingException: org.springframework.integration.MessagingException: No serializer found for class br.com.event.RegisterEvent and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: org.springframework.integration.aws.["payload"])

我是否需要在 Spring 集成上配置任何其他内容?还是我的 bean 有问题 class?

SerializationConfig.Feature ...

看起来您正在以某种方式调用 JSON 序列化 (Jackson),而您的 class 对 Jackson 不友好。

问这样的问题时请出示完整的堆栈轨迹。

想通了。我们用 @JsonProperty 注释了我们的事件(进入队列),如下所示:

@com.fasterxml.jackson.annotation.JsonProperty
private long createdAt;

但是当我们使用 String Integration AWS 时,我们需要使用另一个包中的@JsonProperty。

@org.codehaus.jackson.annotate.JsonProperty
private long createdAt;