qzyReal 1 năm trước cách đây
mục cha
commit
f8c392869e

+ 5 - 3
sp-service/payment-server/src/main/java/com/pj/bank_info/BankInfoController.java

@@ -2,6 +2,7 @@ package com.pj.bank_info;
 
 import java.util.List;
 
+import cn.hutool.log.StaticLog;
 import com.pj.rabbitmq.MessageSender;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -83,9 +84,10 @@ public class BankInfoController {
 
 	@Resource
 	private MessageSender messageSender;
-	@RequestMapping("test")
-	public String test(){
-		messageSender.sendToLevelOneMQ("hello");
+	@PostMapping("test")
+	public String test(@RequestBody String str){
+		StaticLog.info("info:{}",str);
+		messageSender.sendToLevelOneMQ(str);
 		return "hello";
 	}
 

+ 3 - 0
sp-service/payment-server/src/main/java/com/pj/rabbitmq/MessageSender.java

@@ -12,6 +12,7 @@ import org.springframework.amqp.rabbit.annotation.Queue;
 import org.springframework.amqp.rabbit.annotation.RabbitListener;
 import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
 import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
@@ -38,9 +39,11 @@ public class MessageSender {
     }
 
     public void sendToLevelOneMQ(String message) {
+        levelTwoConnectionFactory.setMessageConverter(new Jackson2JsonMessageConverter());
         levelOneConnectionFactory.convertAndSend(rabbitMQProperties.getLevelOneSendQueue(),message);
     }
     public void sendToLevelTwoMQ(String message) {
+        levelTwoConnectionFactory.setMessageConverter(new Jackson2JsonMessageConverter());
         levelTwoConnectionFactory.convertAndSend(rabbitMQProperties.getLevelTwoSendQueue(),message);
     }