java - Apache Camel Multipart Netty Rest DSL 不适用于骆驼杰克逊依赖项
问题描述
我正在尝试使用 netty4-http 读取 multipart/form-data。当我在我的项目中添加了camel-jackson和camel-xstream的依赖项时会出现问题,这会导致JsonParseException,因为我们正在读取multipart/form-data,所以理想情况下不应该发生这种情况。谁可以帮我这个事?
代码很简单,
rest().post("/hello")
.consumes("multipart/form-data")
.produces("application/json")
.to("direct:inbound");
from("direct:inbound")
.routeId("inbound_email")
.process(new PayloadParser())
.process(exchange -> System.out.println("In Body : " + exchange.getIn().getBody()))
.to("log:ie").end();
错误是这样的,
2018-05-09 21:24:48.708 DEBUG 31824 --- [ntExecutorGroup] o.a.c.component.netty4.NettyConsumer : Channel: [id: 0x198248e0, L:/127.0.0.1:8081 - R:/127.0.0.1:65379] received body: HttpObjectAggregator$AggregatedFullHttpRequest(decodeResult: success, version: HTTP/1.1, content: CompositeByteBuf(ridx: 0, widx: 9147, cap: 9147, components=3))
POST /hello HTTP/1.1
Host: localhost:8081
tenantid: 2a721265-bd98-45ec-abc3-f8e81c59e257
Content-Type: multipart/form-data; boundary=--------------------------269100026150164898107684
Content-Length: 9147
2018-05-09 21:24:48.743 DEBUG 31824 --- [ntExecutorGroup] o.a.camel.processor.DefaultErrorHandler : Failed delivery for (MessageId: ID-GSHYD-C02T823UG8WN-local-1525881280467-0-2 on ExchangeId: ID-GSHYD-C02T823UG8WN-local-1525881280467-0-1). On delivery attempt: 0 caught: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('-' (code 45)) in numeric value: expected digit (0-9) to follow minus sign, for valid numeric value
at [Source: (ByteArrayInputStream); line: 1, column: 3]
解决方案
您的 JSON 有效负载中似乎有格式错误的数据 - 不知道您正在尝试做什么 - 解析器似乎正在处理它希望转换为数字但它包含破折号 (-) 的字段。
错误消息中没有问题:
“2018-05-09 21:24:48.743 调试 31824 --- [ntExecutorGroup] oacamel.processor.DefaultErrorHandler:ExchangeId:ID-GSHYD 上的(MessageId:ID-GSHYD-C02T823UG8WN-local-1525881280467-0-2)传递失败-C02T823UG8WN-local-1525881280467-0-1). 交付尝试:0 捕获:com.fasterxml.jackson.core.JsonParseException:数值中的意外字符('-'(代码 45)):预期数字(0-9 ) 跟随减号,用于有效数值 "
推荐阅读
- node.js - 如何获取用户位置和他/她的目的地点之间的距离(以公里为单位)
- angular - Angular 8:等待订阅响应
- python - 如何从 python API azure sdk 获取 Azure 规模集实例的公共 IP?
- ios - 字典中的 NSKeyedArchiver nil 值
- javascript - 带有 ken-burns-out 图像的 Slick Slider 会跳转错误
- html - 无法使用双括号解析变量
- matlab - 如何对 64 次幂进行模 2 加法
- sql-server - 如何检查逗号分隔的字符串值列表是否与整数匹配?
- c++ - 如何在 python3 中使用 ctypes 导入 ostringstream?
- reactjs - 发布与 axios 反应的帖子时如何修复“错误 400 错误请求”?