我正在使用带有远程分块的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& #34;:" 22222"" CCC":" 33333"}]," stepContribution" {" readCount&#34 ;:0," writeCount":0," filterCount":0," readSkipCount":0," writeSkipCount":0,&# 34; processSkipCount":0,"退出状态" {" EXITCODE":"执行"" 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 有效载荷 308个字节 编码:字符串 {"的jobId":0,"项目":[{" AAA":" 11111"" BBB&#34 ;: " 22222"" CCC":" 33333"}]," stepContribution" {" readCount":0, " writeCount":0," filterCount":0," readSkipCount":0," writeSkipCount":0," processSkipCount&# 34;:0,"退出状态" {" EXITCODE":"执行"" exitDescription":"" "运行":真}" SKIPCOUNT":0," stepSkipCount":0},"序列":0}
我使用' Jackson2JsonMessageConverter'作为消息转换为' AmqpOutboundEndpoint'和' AmqpInboundChannelAdapter'
你能帮我吗?
非常感谢。
答案 0 :(得分:0)
ChunkRequest
doesn't support Jackson JSON serialization - 它没有默认的CTOR。
它只支持Java序列化;改为使用SimpleMessageConverter
。
或者写一个自定义杰克逊解串器。