当前位置:网站首页>Message converter (JSON)
Message converter (JSON)
2022-07-19 05:01:00 【Ozawa can't Java】
I said before ,Spring The message you send will be serialized into byte Send to MQ, When receiving messages , It also deserializes bytes into Java object .
It's just , By default Spring The serialization method used is JDK serialize . as everyone knows ,JDK Serialization has the following problems :
The data volume is too large
There are security holes
Poor readability
step
1: Introduce dependencies into the parent project
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.9.10</version>
</dependency>2: Configure bean
@Bean
public MessageConverter jsonMessageConverter(){
return new Jackson2JsonMessageConverter();
}3: Be careful , What does the producer send , What is used by consumers to receive .
for example : I use it here. map Send and receive
consumer
// Set the transmission data format listening queue
@RabbitListener(queues = "object.queue")
public void listenObjectQueue(Map<String,Object> msg){
System.out.println(" Received object.queue The news is :"+msg);
}producer
@Test
public void testSendMap() throws InterruptedException {
// Prepare the news
Map<String,Object> msg = new HashMap<>();
msg.put("name", " Liu Yan ");
msg.put("age", 21);
// Send a message
rabbitTemplate.convertAndSend("object.queue",msg);
}边栏推荐
- Es document operation
- 高等数学笔记:复合函数的二阶导数与参数方程求解曲率
- Differences between substr and substring in JS
- Introduction to redis
- Attendance check-in and leave system based on SSM framework
- 新生任务-5
- Mongo Db单机版的安装和快速使用
- Service end interface test - test point of interface test [Hangzhou multi tester] [Hangzhou multi tester _ Wang Sir]
- CVE-2017-12635 Couchdb 垂直权限绕过漏洞复现
- swagger的坑
猜你喜欢

一文了解配置中心

elment-ui使用方法

【C】张梁计算器

HarmonyOS第四次培训笔记

DSL search results processing, including sorting, paging, highlighting

String字符串根据符号进行特殊截取处理

CVE-2022-23131 Zabbix SAML SSO认证绕过漏洞

MySQL takes the union of two query conditions and then queries
[email protected] : `node install. Problems of js`"/>solve [email protected] : `node install. Problems of js`

pygame安装-Requirement already satisfied问题
随机推荐
UE plug-in electronicnodes 5.0.0/4.23-4.27
Learn about scheduled tasks in one article
中台的订单系统
SMS verification test without signature template audit
The difference between junit4 and junit5
shardingsphere内核原理
渗透测试 10 --- 扫描 web目录 (dirb、wfuzz、wpscan、nikto)
redis 安装
Chat about global filter
消息转换器(json)
Desensitization field example
SQL语句学习
Introduction to redis
Redis installation
shardingsphere的核心概念和快速实战
HarmonyOS第四次培训笔记
拥抱声明式UI
负载均衡器ribbon实战
Implementation idea of log adding to database
Cve-2020-10199 recurrence of nexus repository manager3 remote command execution vulnerability