1.延迟接收消息,防止出现线程吃满
This commit is contained in:
@@ -12,6 +12,7 @@ import com.yupi.springbootinit.service.ServerBigBrotherService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -44,7 +45,7 @@ public class MQReceiver {
|
||||
// }
|
||||
// }
|
||||
|
||||
@RabbitListener(queues = "HOST_INFO_QUEUE")
|
||||
@RabbitListener(queues = "HOST_INFO_QUEUE",id = "hosts", autoStartup = "false")
|
||||
@Async("taskExecutor")
|
||||
public void receive(List<NewHosts> hosts, Channel channel, Message message) throws IOException {
|
||||
long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
||||
@@ -61,7 +62,7 @@ public class MQReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
@RabbitListener(queues = "BIG_BROTHER_QUEUE")
|
||||
@RabbitListener(queues = "BIG_BROTHER_QUEUE",id = "bigbrother", autoStartup = "false")
|
||||
@Async("taskExecutor")
|
||||
public void bigBrotherReceive(ServerBigBrother bigBrotherList, Channel channel, Message message) throws IOException {
|
||||
long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
||||
|
||||
Reference in New Issue
Block a user