mirror of
https://github.com/luoye663/e5.git
synced 2024-12-26 03:38:53 +00:00
队列处理访问邮件列表
This commit is contained in:
parent
823bfbdbd2
commit
5c7096fbf9
9
pom.xml
9
pom.xml
@ -76,8 +76,15 @@
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.62</version>
|
||||
<version>1.2.68</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
|
@ -1,5 +1,9 @@
|
||||
package io.qyi.e5.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.google.gson.Gson;
|
||||
import io.qyi.e5.outlook.entity.Outlook;
|
||||
import io.qyi.e5.outlook.service.IOutlookService;
|
||||
import org.springframework.amqp.core.MessageProperties;
|
||||
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
@ -22,12 +26,15 @@ public class TestController {
|
||||
@Autowired
|
||||
RabbitTemplate rabbitTemplate;
|
||||
|
||||
@Autowired
|
||||
IOutlookService outlookService;
|
||||
|
||||
@GetMapping("/send")
|
||||
public void aaa() {
|
||||
CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
|
||||
Outlook Outlook = outlookService.getOne(new QueryWrapper<Outlook>().eq("github_id", 19658189));
|
||||
|
||||
|
||||
rabbitTemplate.convertAndSend("delay", "delay", "ttt", message -> {
|
||||
rabbitTemplate.convertAndSend("delay", "delay", Outlook, message -> {
|
||||
MessageProperties messageProperties = message.getMessageProperties();
|
||||
// 设置这条消息的过期时间
|
||||
messageProperties.setExpiration("5000");
|
||||
|
@ -171,7 +171,6 @@ public class OutlookServiceImpl extends ServiceImpl<OutlookMapper, Outlook> impl
|
||||
String s = OkHttpRequestUtils.doGet("https://graph.microsoft.com/v1.0/me/messages?$select=sender,subject", head, null);
|
||||
logger.info("请求邮件列表返回数据:" + s);
|
||||
return s;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,6 +2,7 @@ package io.qyi.e5.outlook_log.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.google.gson.Gson;
|
||||
import io.qyi.e5.config.security.UsernamePasswordAuthenticationToken;
|
||||
import io.qyi.e5.outlook.entity.Outlook;
|
||||
import io.qyi.e5.outlook.service.IOutlookService;
|
||||
@ -16,6 +17,7 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -45,24 +47,16 @@ public class OutlookLogController {
|
||||
private int pageSize;
|
||||
|
||||
@GetMapping("/findLog")
|
||||
@ResponseBody
|
||||
public String findLog(Model model){
|
||||
UsernamePasswordAuthenticationToken authentication = (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||
int github_id = authentication.getGithub_id();
|
||||
/*QueryWrapper<OutlookLog> wrapper = new QueryWrapper();
|
||||
wrapper.eq("github_id", github_id);
|
||||
Page<OutlookLog> page = new Page<>(8,pageSize);
|
||||
|
||||
IPage<Map<String, Object>> mapIPage = outlookLogMapper.selectMapsPage(page, wrapper);
|
||||
System.out.println("总页数"+mapIPage.getPages());
|
||||
System.out.println("总记录数"+mapIPage.getTotal());
|
||||
List<Map<String, Object>> records = mapIPage.getRecords();
|
||||
records.forEach(System.out::println);*/
|
||||
|
||||
QueryWrapper<OutlookLog> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("github_id", github_id);
|
||||
List<OutlookLog> list = outlookLogService.list(queryWrapper);
|
||||
model.addAttribute("list_log", list);
|
||||
return "/outlookLog/findLog";
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(list);
|
||||
}
|
||||
|
||||
@GetMapping("/exec111111")
|
||||
|
@ -2,7 +2,9 @@ package io.qyi.e5.service.rabbitMQ.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import io.qyi.e5.outlook.entity.Outlook;
|
||||
import io.qyi.e5.outlook.service.IOutlookService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -13,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
* @program: msgpush
|
||||
@ -30,7 +33,15 @@ public class ListenerImpl {
|
||||
@RabbitHandler
|
||||
@RabbitListener(queues = "delay_queue2", containerFactory = "rabbitListenerContainerFactory")
|
||||
public void listen(Message message, Channel channel) throws IOException {
|
||||
logger.info("消费者1开始处理消息: {},时间戳:{}" ,new String(message.getBody()),System.currentTimeMillis());
|
||||
String body = new String(message.getBody());
|
||||
logger.info("消费者1开始处理消息: {},时间戳:{}" ,body,System.currentTimeMillis());
|
||||
try {
|
||||
Gson gson = new Gson();
|
||||
Outlook outlook = gson.fromJson(body, Outlook.class);
|
||||
outlookService.getMailList(outlook);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user