远程分块:无法从JSON对象实例化

问题描述 投票:0回答:1

我正在使用带有远程分块的spring批处理,我有以下问题:当请求队列中的master publih事件使用json格式(application / json)时,当slave读取此json事件时,我有一个异常。

例外:

引起:com.fasterxml.jackson.databind.JsonMappingException:找不到类型[simple type,class org.springframework.batch.integration.chunk.ChunkRequest]的合适构造函数:无法从JSON对象实例化(缺少默认构造函数或创建者,或者可能需要添加/启用类型信息?)在[来源:{“jobId”:0,“items”:[{“aaa”:“11111”,“bbb”:“22222”,“ccc”:“33333 “}],” stepContribution “:{” readCount “:0”,writeCount “:0”,filterCount “:0”,readSkipCount “:0”,writeSkipCount “:0”,processSkipCount “:0,” 退出状态“:{ “EXITCODE”: “EXECUTING”, “exitDescription”: “”, “跑”:真}, “SKIPCOUNT”:0 “stepSkipCount”:0}, “序列”:0}; line:1,column:2]

RabbitMQ消息:

标题: TypeId:org.springframework.batch.integration.chunk.ChunkRequest content_encoding:UTF-8 content_type:application / json Payload 308 bytes Encoding:string {“jobId”:0,“items”:[{“aaa”:“11111”, “BBB”: “22222”, “CCC”: “33333”}], “stepContribution”:{ “readCount”:0 “writeCount”:0 “filterCount”:0 “readSkipCount”:0, “writeSkipCount” :0, “processSkipCount”:0, “退出状态”:{ “EXITCODE”: “EXECUTING”, “exitDescription”: “”, “跑”:真}, “SKIPCOUNT”:0 “stepSkipCount”:0},”序列“:0}

我使用'Jackson2JsonMessageConverter'作为'AmqpOutboundEndpoint'和'AmqpInboundChannelAdapter'的消息转换器

你能帮我吗?

非常感谢。

spring-integration spring-batch
1个回答
0
投票

ChunkRequest doesn't support Jackson JSON serialization - 它没有默认的CTOR。

它只支持Java序列化;使用SimpleMessageConverter代替。

或者写一个自定义杰克逊解串器。

© www.soinside.com 2019 - 2024. All rights reserved.