{"record":{"id":"8566eb522d660815","repo":"paascloud/paascloud-master","slug":"mq-json","errorCode":null,"errorMessage":"处理MQ信息,JSON转换异常","messagePattern":"处理MQ信息,JSON转换异常","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-opc/src/main/java/com/paascloud/provider/consumer/OptSendEmailTopicConsumer.java","lineNumber":51,"sourceCode":"\t@Resource\n\tprivate OptSendMailService optSendMailService;\n\n\t/**\n\t * Handler send email topic.\n\t *\n\t * @param body      the body\n\t * @param topicName the topic name\n\t * @param tags      the tags\n\t * @param keys      the keys\n\t */\n\tpublic void handlerSendEmailTopic(String body, String topicName, String tags, String keys) {\n\t\tMqMessage.checkMessage(body, keys, topicName);\n\t\tPcSendEmailRequest request;\n\t\ttry {\n\t\t\trequest = JacksonUtil.parseJson(body, PcSendEmailRequest.class);\n\t\t} catch (Exception e) {\n\t\t\tlog.error(\"发送短信MQ出现异常={}\", e.getMessage(), e);\n\t\t\tthrow new IllegalArgumentException(\"处理MQ信息,JSON转换异常\");\n\t\t}\n\t\tString subject = request.getSubject();\n\t\tString text = request.getText();\n\t\tSet<String> to = request.getTo();\n\t\toptSendMailService.sendTemplateMail(subject, text, to);\n\t}\n}\n","sourceCodeStart":33,"sourceCodeEnd":59,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-opc/src/main/java/com/paascloud/provider/consumer/OptSendEmailTopicConsumer.java#L33-L59","documentation":"IllegalArgumentException(\"处理MQ信息,JSON转换异常\") thrown by OptSendEmailTopicConsumer.handlerSendEmailTopic when the email-topic message body cannot be parsed into PcSendEmailRequest. The topic consumer expects a JSON payload produced by the email producer; any parse failure aborts handling so the broker can dead-letter the bad message.","triggerScenarios":"MQ body on the send-email topic is not valid JSON for PcSendEmailRequest: null/empty body (partially guarded by MqMessage.checkMessage), wrong field names/types versus the DTO, or a producer sending a legacy payload format.","commonSituations":"Version skew after adding/removing fields on PcSendEmailRequest; producer accidentally sends the SMS request object to the email topic; body passed through toString instead of Jackson serialization; charset/encoding corruption in transit.","solutions":["Inspect the logged message body to confirm whether it is malformed JSON or a field mismatch","Align the producer's serialization (JacksonUtil.toJson) with PcSendEmailRequest and redeploy both sides","Verify the right topic is used for email vs sms messages","Republish a correctly serialized PcSendEmailRequest to flush the queue"],"exampleFix":"// before\nrequest = JacksonUtil.parseJson(body, PcSendEmailRequest.class);\n// after\nif (PublicUtil.isEmpty(body)) { log.warn(\"skip empty email body, topic={}\", topicName); return; }\nrequest = JacksonUtil.parseJson(body, PcSendEmailRequest.class);","handlingStrategy":"try-catch","validationCode":"if (PublicUtil.isEmpty(body)) { log.warn(\"skip empty email MQ body\"); return; }\n// producer side:\nMqMessage.checkMessage(body, keys, topicName);","typeGuard":null,"tryCatchPattern":"try {\n    request = JacksonUtil.parseJson(body, PcSendEmailRequest.class);\n} catch (Exception e) {\n    log.error(\"bad email MQ body={}\", body, e);\n    return; // dead-letter instead of rethrowing into infinite retry\n}","preventionTips":["Publish only Jackson-serialized PcSendEmailRequest to the email topic","Separate email and sms topics/DTOs to avoid cross-publishing","Version the message schema and deploy producer/consumer together","Log the raw body on parse failure for diagnosis"],"tags":["mq-consumer","jackson","deserialization","email"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"781281a9503332ed3cef44ea618349d14230a127","analyzedAt":"2026-09-10T10:59:02.070Z","contentChangedAt":"2026-09-10T10:59:02.070Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}