|
@@ -1,11 +1,12 @@
|
|
|
package com.free.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.free.config.CustomizationException;
|
|
|
import com.free.config.ExceptionEnum;
|
|
|
import com.free.config.ResponseFormat;
|
|
|
import com.free.entity.Test;
|
|
|
-import com.free.mq.MqListeners;
|
|
|
+import com.free.mq.MqService;
|
|
|
import com.free.service.TestService;
|
|
|
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
@@ -25,11 +26,12 @@ public class TestController {
|
|
|
@Autowired
|
|
|
private TestService testService;
|
|
|
|
|
|
+
|
|
|
@Autowired
|
|
|
- RabbitTemplate rabbitTemplate; // 使用RabbitTemplate,这提供了接收/发送等等方法
|
|
|
+ MqService mqService;
|
|
|
|
|
|
@GetMapping("/mq/send")
|
|
|
- public Object mqSendTest() {
|
|
|
+ public Object mqSendTest() throws JsonProcessingException {
|
|
|
String messageId = String.valueOf(UUID.randomUUID());
|
|
|
String messageData = "message: M A N ";
|
|
|
String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
@@ -37,7 +39,7 @@ public class TestController {
|
|
|
manMap.put("messageId", messageId);
|
|
|
manMap.put("messageData", messageData);
|
|
|
manMap.put("createTime", createTime);
|
|
|
- rabbitTemplate.convertAndSend(MqListeners.exName, MqListeners.queueName + "1", manMap);
|
|
|
+ mqService.sendMsg("chatEx", "chat.1", manMap);
|
|
|
return ResponseFormat.success();
|
|
|
}
|
|
|
|