Comments (3)
依赖名称:concept-netty-loadbalance-spring-boot-starter
依赖版本:2.3.0 、 2.3.2
问题描述:使用rabbimq转发UserMessage消息 BaseMessageCodecAdapter.getForwardMessageDecoder 方法下的 JacksonForwardMessageDecoder.readTree(Object message)抛出异常。mq转发消息Object message 类型(org.springframework.amqp.core.Message)
代码示例: 修复重写方法: @SneakyThrows protected JsonNode readTree(Object message) { if (message instanceof String strMessage) { return objectMapper.readTree(strMessage); } if (message instanceof Message mqMessage) { return objectMapper.readTree((mqMessage.getBody())); } if (message instanceof ByteBuffer byteBuffer) { return objectMapper.readTree(byteBuffer.array()); } if (message instanceof byte[]) { return objectMapper.readTree((byte[]) message); } throw new MessageDecodeException(message); }
我这边 2.3.2 没有复现,rabbitmq message 的处理在 RabbitMessageCodecAdapter,能提供更详细的信息吗
from concept.
我测试了一下, 确认在2.3.2中没有复现了。另外提一个改进的小建议:同一个类的decode 方法的else逻辑, 如果传递的是json字符串, jar中使用的payloadNode.asText() 方法会传递为空字符串, 建议的改进如下:
TextMessage decoded = new TextMessage();
decoded.setHeaders(headers);
if (payloadNode.isTextual()) {
decoded.setPayload(payloadNode.asText());
} else if (payloadNode.isObject()) {
decoded.setPayload(payloadNode.toString());
}
return decoded;
判断传递的是字符串还是对象, 进行分别处理。
from concept.
我测试了一下, 确认在2.3.2中没有复现了。另外提一个改进的小建议:同一个类的decode 方法的else逻辑, 如果传递的是json字符串, jar中使用的payloadNode.asText() 方法会传递为空字符串, 建议的改进如下:
TextMessage decoded = new TextMessage();
decoded.setHeaders(headers);
if (payloadNode.isTextual()) {
decoded.setPayload(payloadNode.asText());
} else if (payloadNode.isObject()) {
decoded.setPayload(payloadNode.toString());
}
return decoded;
判断传递的是字符串还是对象, 进行分别处理。
2.3.3版本已经修改
from concept.
Related Issues (20)
- 启动多个服务实例,实例之间无法连接 HOT 11
- 如果发送消息量过大或者base64图片的时候会直接关闭socket能够通过配置解决? HOT 16
- 支持不用注册中心的版本吗? HOT 1
- 使用websocket网关服务报readAddress(..) failed: Connection reset by peer HOT 12
- 长文本支持要怎么设置 HOT 1
- 异步回调转为同步返回 HOT 5
- 发现发送消息会一直占用 发生java.lang.OutOfMemoryError: Java heap space HOT 12
- 消息转发json转义 HOT 13
- websocket连接过多 HOT 2
- 如何主动关闭集群其它机器的 websocket 连接 HOT 2
- springboot3.2.4 Download组件报错 HOT 2
- SpringBoot 3.2.5 Download组件报错
- 自身实例去连接其他实例时报404 HOT 8
- 如果有server.servlet.context-path的话会导致自身实例连接订阅其他实例失败且PathMessage全部变成死信消息导致接收不到 HOT 3
- 批量发送concept.send(..) HOT 1
- concept-downlaod 下载文件可以指定目录么, HOT 7
- concept-downlaod可以下载到服务器指定路径 HOT 34
- 大量websocket连接优化 HOT 44
- websocket如何鉴权 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from concept.