mirror of
https://github.com/luoye663/e5.git
synced 2024-12-26 11:48:50 +00:00
临时更改为异步执行
This commit is contained in:
parent
6591358b8c
commit
37e40bdcd8
@ -84,6 +84,10 @@ public class RabbitMQConfig {
|
|||||||
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
|
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
|
||||||
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
|
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
|
||||||
factory.setAcknowledgeMode(AcknowledgeMode.MANUAL);
|
factory.setAcknowledgeMode(AcknowledgeMode.MANUAL);
|
||||||
|
factory.setConcurrentConsumers(1);
|
||||||
|
factory.setMaxConcurrentConsumers(20);
|
||||||
|
factory.setPrefetchCount(20);
|
||||||
|
|
||||||
factory.setConnectionFactory(connectionFactory);
|
factory.setConnectionFactory(connectionFactory);
|
||||||
factory.setMessageConverter(new Jackson2JsonMessageConverter());
|
factory.setMessageConverter(new Jackson2JsonMessageConverter());
|
||||||
return factory;
|
return factory;
|
||||||
|
@ -40,18 +40,7 @@ public class ListenerImpl {
|
|||||||
logger.info("消费者1开始处理消息: {},时间戳:{}" ,message,System.currentTimeMillis());
|
logger.info("消费者1开始处理消息: {},时间戳:{}" ,message,System.currentTimeMillis());
|
||||||
System.out.println("消费者1开始处理消息:"+System.currentTimeMillis());
|
System.out.println("消费者1开始处理消息:"+System.currentTimeMillis());
|
||||||
int github_id = Integer.valueOf(new String(message.getBody()));
|
int github_id = Integer.valueOf(new String(message.getBody()));
|
||||||
try {
|
Task.executeE5(github_id);
|
||||||
Outlook Outlook = outlookService.getOne(new QueryWrapper<Outlook>().eq("github_id", github_id));
|
|
||||||
if (Outlook == null) {
|
|
||||||
logger.warn("未找到此用户,github_id: {}",github_id);
|
|
||||||
/*这里也发送ack,不然会照成队列堆积*/
|
|
||||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
outlookService.getMailList(Outlook);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
|
||||||
/*再次进行添加任务*/
|
/*再次进行添加任务*/
|
||||||
Task.sendTaskOutlookMQ(github_id);
|
Task.sendTaskOutlookMQ(github_id);
|
||||||
|
@ -10,4 +10,6 @@ public interface ITask {
|
|||||||
void sendTaskOutlookMQ(int github_id);
|
void sendTaskOutlookMQ(int github_id);
|
||||||
void sendTaskOutlookMQALL();
|
void sendTaskOutlookMQALL();
|
||||||
|
|
||||||
|
void executeE5(int github_id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,11 +60,23 @@ public class TaskImpl implements ITask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Async
|
||||||
|
public void executeE5(int github_id) {
|
||||||
|
Outlook Outlook = outlookService.getOne(new QueryWrapper<Outlook>().eq("github_id", github_id));
|
||||||
|
if (Outlook == null) {
|
||||||
|
logger.warn("未找到此用户,github_id: {}", github_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
outlookService.getMailList(Outlook);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送消息到队列
|
* 发送消息到队列
|
||||||
|
*
|
||||||
|
* @param Expiration
|
||||||
* @Description:
|
* @Description:
|
||||||
* @param: * @param msg
|
* @param: * @param msg
|
||||||
* @param Expiration
|
|
||||||
* @return: void
|
* @return: void
|
||||||
* @Author: 落叶随风
|
* @Author: 落叶随风
|
||||||
* @Date: 2020/4/16
|
* @Date: 2020/4/16
|
||||||
@ -82,9 +94,10 @@ public class TaskImpl implements ITask {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成随机数
|
* 生成随机数
|
||||||
|
*
|
||||||
|
* @param end
|
||||||
* @Description:
|
* @Description:
|
||||||
* @param: * @param start
|
* @param: * @param start
|
||||||
* @param end
|
|
||||||
* @return: java.lang.String
|
* @return: java.lang.String
|
||||||
* @Author: 落叶随风
|
* @Author: 落叶随风
|
||||||
* @Date: 2020/4/16
|
* @Date: 2020/4/16
|
||||||
|
@ -42,7 +42,7 @@ public class dome01 {
|
|||||||
@Test
|
@Test
|
||||||
public void r(){
|
public void r(){
|
||||||
for (int i = 0; i < 30; i++) {
|
for (int i = 0; i < 30; i++) {
|
||||||
System.out.println(getRandom(60,120));
|
System.out.println(getRandom(3600,7200));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user