添加大哥数据入库接口
This commit is contained in:
@@ -4,9 +4,11 @@ import cn.hutool.core.date.DateTime;
|
||||
import com.yupi.springbootinit.common.ErrorCode;
|
||||
import com.yupi.springbootinit.exception.BusinessException;
|
||||
import com.yupi.springbootinit.model.entity.NewHosts;
|
||||
import com.yupi.springbootinit.model.entity.ServerBigBrother;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -21,7 +23,7 @@ public class MQSender {
|
||||
|
||||
|
||||
//方法:发送消息
|
||||
public void send(List<NewHosts> list){
|
||||
public void hostsSend(List<NewHosts> list){
|
||||
try {
|
||||
// log.info("{} 接收到的消息数量----------->{}", DateTime.now(),list.size());
|
||||
this.rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
|
||||
@@ -30,6 +32,16 @@ public class MQSender {
|
||||
}catch (Exception e){
|
||||
throw new BusinessException(ErrorCode.QUEUE_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
//方法:发送消息
|
||||
public void bigBrotherSend(ServerBigBrother bigBrothers){
|
||||
try {
|
||||
// log.info("{} 接收到的消息数量----------->{}", DateTime.now(),list.size());
|
||||
this.rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
|
||||
//指定你队列的名字
|
||||
rabbitTemplate.convertAndSend("BIG_BROTHER_QUEUE",bigBrothers);
|
||||
}catch (Exception e){
|
||||
throw new BusinessException(ErrorCode.QUEUE_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user