...
|
...
|
@@ -5,8 +5,11 @@ import com.sunyo.wlpt.message.bus.service.exception.CustomExceptionType; |
|
|
import com.sunyo.wlpt.message.bus.service.rabbit.utils.DirectUtils;
|
|
|
import com.sunyo.wlpt.message.bus.service.rabbit.utils.RabbitUtils;
|
|
|
import com.sunyo.wlpt.message.bus.service.response.ResultJson;
|
|
|
import com.sunyo.wlpt.message.bus.service.service.AsyncTaskService;
|
|
|
import com.sunyo.wlpt.message.bus.service.service.MessageNoteService;
|
|
|
import com.sunyo.wlpt.message.bus.service.service.UserMessageBindingService;
|
|
|
import com.sunyo.wlpt.message.bus.service.utils.XmlUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.dom4j.DocumentException;
|
|
|
import org.springframework.format.annotation.DateTimeFormat;
|
|
|
import org.springframework.web.bind.annotation.*;
|
...
|
...
|
@@ -21,6 +24,7 @@ import java.util.concurrent.TimeoutException; |
|
|
* Description:
|
|
|
* 时间:2020/7/16 14:46
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@CrossOrigin
|
|
|
@RequestMapping("bus/rabbit")
|
|
|
@RestController
|
...
|
...
|
@@ -32,11 +36,17 @@ public class RabbitController { |
|
|
private XmlUtils xmlUtils;
|
|
|
|
|
|
@Resource
|
|
|
private MessageNoteService messageNoteService;
|
|
|
|
|
|
@Resource
|
|
|
private RabbitUtils rabbitUtils;
|
|
|
|
|
|
@Resource
|
|
|
private DirectUtils directUtils;
|
|
|
|
|
|
@Resource
|
|
|
private AsyncTaskService asyncTaskService;
|
|
|
|
|
|
@GetMapping("/test/consumer")
|
|
|
public void consumer() throws IOException, TimeoutException
|
|
|
{
|
...
|
...
|
@@ -103,8 +113,20 @@ public class RabbitController { |
|
|
return ResultJson.error(CustomExceptionType.BINDING_ERROR);
|
|
|
}
|
|
|
// 4、mq发送消息,数据库中保存消息
|
|
|
ResultJson result = directUtils.sendMessage(sentData);
|
|
|
// ResultJson result = directUtils.sendMessage(sentData);
|
|
|
// if (CustomExceptionType.MESSAGE_SUCCESS.getCode().equals(result.getCode())) {
|
|
|
// // mq发送消息成功之后,将消息存储于数据库
|
|
|
// messageNoteService.insertMessageSelective(sentData);
|
|
|
// }
|
|
|
return sendAndSave(sentData);
|
|
|
}
|
|
|
|
|
|
public ResultJson sendAndSave(XmlData sentData) throws Exception
|
|
|
{
|
|
|
// 4、mq发送消息,数据库中保存消息
|
|
|
ResultJson result = directUtils.sendMessage(sentData);
|
|
|
// 异步,保存消息记录
|
|
|
asyncTaskService.saveMessage(sentData);
|
|
|
return result;
|
|
|
}
|
|
|
} |
...
|
...
|
|