提交 73e90d9c authored 作者: Matrix's avatar Matrix

Initial commit

上级
File added
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.matrix</groupId>
<artifactId>consumer-A</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>consumer-A</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.78</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
package com.matrix.cona;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
public class ConsumerAApplication {
public static void main(String[] args) {
SpringApplication.run(ConsumerAApplication.class, args);
}
}
package com.matrix.cona.config;
import org.springframework.context.annotation.Configuration;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* 配置跨域
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 2:33 PM
* Suffering is the most powerful teacher of life.
*/
@Configuration
public class CorsConfig implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
Filter.super.init(filterConfig);
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) servletResponse;
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE, PATCH");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers", "Origin, Content-Type, Accept");
response.setHeader("Access-Control-Expose-Headers", "Location");
filterChain.doFilter(servletRequest, servletResponse);
}
@Override
public void destroy() {
Filter.super.destroy();
}
}
package com.matrix.cona.config;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.jms.core.JmsTemplate;
import javax.jms.ConnectionFactory;
/**
* JmsConfig.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/4 at 4:48 下午
*/
@Configuration
public class JmsConfig {
@Autowired
private Environment env;
@Bean
public ConnectionFactory connectionFactory() {
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL(env.getProperty("spring.activemq.broker-url"));
connectionFactory.setUserName(env.getProperty("spring.activemq.user"));
connectionFactory.setPassword(env.getProperty("spring.activemq.password"));
return connectionFactory;
}
@Bean
public JmsTemplate genJmsTemplate() {
return new JmsTemplate(connectionFactory());
}
@Bean
public JmsMessagingTemplate jmsMessageTemplate() {
return new JmsMessagingTemplate(connectionFactory());
}
}
package com.matrix.cona.controller;
import com.alibaba.fastjson.JSON;
import com.matrix.cona.entity.StandardData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Controller.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/30 at 6:22 下午
* Suffering is the most powerful teacher of life.
*/
@RestController
@RequestMapping("/test")
public class TestController {
private final String mailEndpoints = "mail";
@Autowired
private JmsMessagingTemplate jmsTemplate;
/**
* 将邮件内容发送到 邮件标准下的端点
*
* @param standardData 标准邮件内容
* @return ResponseEntity
*/
@PostMapping("/mail")
public ResponseEntity<String> sendMail(@RequestBody StandardData standardData) {
jmsTemplate.convertAndSend(mailEndpoints, JSON.toJSON(standardData).toString());
// Map<String, String> result = new HashMap<>();
// result.put("code", "200");
// result.put("message", "success");
return ResponseEntity.ok("发送成功");
}
}
package com.matrix.cona.entity;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
/**
* CustomBeans.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 1:03 上午
* Suffering is the most powerful teacher of life.
*/
@Configuration
public class CustomBeans {
@Bean
public RestTemplate restTemplate(){
return new RestTemplate();
}
@Bean
public ObjectMapper objectMapper(){
return new ObjectMapper();
}
}
package com.matrix.cona.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* MailInfo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 1:44 上午
* Suffering is the most powerful teacher of life.
*/
@Data
@ApiModel("邮件信息体")
public class MailInfo {
@ApiModelProperty(value = "邮件主题",example = "测试主题")
private String title;
@ApiModelProperty(value = "发送的邮件终点地址",example = "xhyrzldf@gmail.com")
private String mailAddress;
@ApiModelProperty(value = "发送的邮件内容",example = "This is a test mail")
private String content;
}
package com.matrix.cona.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* ServerInfo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 12:43 上午
* Suffering is the most powerful teacher of life.
*/
@Data
@ApiModel("服务器信息,模拟服务注册")
public class ServerInfo {
@ApiModelProperty("组件编号")
private String comNumber;
@ApiModelProperty("组件地址")
private String comAddress;
}
package com.matrix.cona.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* StandardData.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/30 at 5:17 下午
* Suffering is the most powerful teacher of life.
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("向总线通信的标准数据")
public class StandardData {
@ApiModelProperty("该消息来自于哪个组件-组件名(demo)")
private String from;
@ApiModelProperty("该消息要发送的接口地址")
private String api;
@ApiModelProperty("该消息的数据内容")
private MailInfo data;
}
package com.matrix.cona.tasks;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
/**
* ScheduledTasks.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 1:05 上午
* Suffering is the most powerful teacher of life.
*/
@Component
@Slf4j
public class ScheduledTasks {
@Autowired
private RestTemplate restTemplate;
@Autowired
private ObjectMapper objectMapper;
private String registerUrl = "http://localhost:8180/server/register";
/**
* 每30秒进行一次心跳
*/
@Scheduled(initialDelay = 5000, fixedRate = 30000)
public void registerAndHeartBeat() {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
ObjectNode serverNode = objectMapper.createObjectNode();
serverNode.put("comNumber", "x000x001");
serverNode.put("comAddress", "127.0.0.1");
HttpEntity<String> request = new HttpEntity<>(serverNode.toString(), headers);
String result = null;
try {
result = restTemplate.postForObject(registerUrl, request, String.class);
} catch (RestClientException e) {
log.debug("[componentA] 没有找到消息总线服务器...");
}
log.info("register success , response = {}", result);
}
}
# Settings
server.port= 7999
# ActiveMQ
spring.activemq.broker-url=tcp://127.0.0.1:61616
spring.activemq.user=admin
spring.activemq.password=admin
spring.activemq.pool.enabled=true
spring.activemq.pool.max-connections=100
# Log
logging.file.name=log/consumer-a.log
package com.matrix.cona;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class ConsumerAApplicationTests {
@Test
void contextLoads() {
}
}
2022-05-07 16:16:32.846 INFO 43204 --- [main] com.matrix.cona.ConsumerAApplication : Starting ConsumerAApplication using Java 1.8.0_201 on MacBook-Pro.local with PID 43204 (/Users/matrix/code/gitlab/message-demo/consumer-A/target/classes started by matrix in /Users/matrix/code/gitlab/message-demo)
2022-05-07 16:16:32.853 INFO 43204 --- [main] com.matrix.cona.ConsumerAApplication : No active profile set, falling back to default profiles: default
2022-05-07 16:16:34.455 INFO 43204 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 7999 (http)
2022-05-07 16:16:34.466 INFO 43204 --- [main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-05-07 16:16:34.466 INFO 43204 --- [main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.39]
2022-05-07 16:16:34.539 INFO 43204 --- [main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-05-07 16:16:34.539 INFO 43204 --- [main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1621 ms
2022-05-07 16:16:35.154 INFO 43204 --- [main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2022-05-07 16:16:35.316 INFO 43204 --- [main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'taskScheduler'
2022-05-07 16:16:35.394 INFO 43204 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 7999 (http) with context path ''
2022-05-07 16:16:35.809 INFO 43204 --- [main] com.matrix.cona.ConsumerAApplication : Started ConsumerAApplication in 3.326 seconds (JVM running for 3.936)
2022-05-07 16:16:40.842 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = null
2022-05-07 16:17:10.850 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:17:40.840 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:18:10.836 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:18:40.830 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:19:10.831 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:19:40.872 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:20:10.852 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:20:40.868 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:21:10.864 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:21:40.873 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:22:10.871 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:22:40.868 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:23:10.859 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:23:40.861 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:24:10.866 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:24:40.856 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:25:10.851 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:25:40.845 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:26:10.853 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:26:40.852 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:27:10.857 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:27:40.854 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:28:10.854 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:28:40.859 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:29:10.854 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:29:40.846 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:30:10.855 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:30:40.851 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:31:10.860 INFO 43204 --- [scheduling-1] com.matrix.cona.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:31:19.903 INFO 43204 --- [SpringContextShutdownHook] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 'taskScheduler'
2022-05-07 16:31:19.906 INFO 43204 --- [SpringContextShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2022-05-07 16:16:51.971 INFO 43356 --- [main] com.matrix.mail.qq.MailQqApplication : Starting MailQqApplication using Java 1.8.0_201 on MacBook-Pro.local with PID 43356 (/Users/matrix/code/gitlab/message-demo/mail-qq/target/classes started by matrix in /Users/matrix/code/gitlab/message-demo)
2022-05-07 16:16:51.980 INFO 43356 --- [main] com.matrix.mail.qq.MailQqApplication : No active profile set, falling back to default profiles: default
2022-05-07 16:16:53.530 INFO 43356 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8182 (http)
2022-05-07 16:16:53.538 INFO 43356 --- [main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-05-07 16:16:53.538 INFO 43356 --- [main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.39]
2022-05-07 16:16:53.605 INFO 43356 --- [main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-05-07 16:16:53.605 INFO 43356 --- [main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1565 ms
2022-05-07 16:16:54.391 INFO 43356 --- [main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'taskScheduler'
2022-05-07 16:16:54.471 INFO 43356 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8182 (http) with context path ''
2022-05-07 16:16:55.057 INFO 43356 --- [main] com.matrix.mail.qq.MailQqApplication : Started MailQqApplication in 3.466 seconds (JVM running for 4.038)
2022-05-07 16:17:00.307 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:17:30.105 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:18:00.076 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:18:30.094 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:19:00.075 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:19:30.104 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:20:00.109 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:20:30.109 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:21:00.120 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:21:30.110 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:22:00.117 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:22:30.126 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:23:00.114 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:23:30.105 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:24:00.109 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:24:30.107 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:25:00.114 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:25:30.098 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:26:00.119 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:26:30.112 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:27:00.103 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:27:30.130 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:28:00.112 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:28:30.101 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:29:00.104 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:29:30.114 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:30:00.102 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:30:30.113 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:31:00.111 INFO 43356 --- [scheduling-1] com.matrix.mail.qq.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:16:59.419 INFO 43412 --- [main] c.matirx.mail.gmail.SinaMailApplication : Starting SinaMailApplication using Java 1.8.0_201 on MacBook-Pro.local with PID 43412 (/Users/matrix/code/gitlab/message-demo/mail-163/target/classes started by matrix in /Users/matrix/code/gitlab/message-demo)
2022-05-07 16:16:59.428 INFO 43412 --- [main] c.matirx.mail.gmail.SinaMailApplication : No active profile set, falling back to default profiles: default
2022-05-07 16:17:00.917 INFO 43412 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8181 (http)
2022-05-07 16:17:00.924 INFO 43412 --- [main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-05-07 16:17:00.925 INFO 43412 --- [main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.39]
2022-05-07 16:17:00.986 INFO 43412 --- [main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-05-07 16:17:00.986 INFO 43412 --- [main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1498 ms
2022-05-07 16:17:01.708 INFO 43412 --- [main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'taskScheduler'
2022-05-07 16:17:01.784 INFO 43412 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8181 (http) with context path ''
2022-05-07 16:17:02.356 INFO 43412 --- [main] c.matirx.mail.gmail.SinaMailApplication : Started SinaMailApplication in 3.316 seconds (JVM running for 3.877)
2022-05-07 16:17:07.422 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:17:37.390 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:18:07.384 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:18:37.373 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:19:07.384 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:19:37.410 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:20:07.405 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:20:37.399 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:21:07.417 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:21:37.417 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:22:07.409 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:22:37.409 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:23:07.421 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:23:37.416 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:24:07.406 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:24:37.417 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:25:07.392 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:25:37.424 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:26:07.396 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:26:37.402 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:27:07.404 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:27:37.413 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:28:07.408 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:28:37.392 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:29:07.414 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:29:37.402 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:30:07.406 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:30:37.411 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2022-05-07 16:31:07.417 INFO 43412 --- [scheduling-1] c.m.mail.gmail.tasks.ScheduledTasks : register success , response = register success
2021-12-07 00:20:19.463 WARN 13237 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=17m48s634ms).
2021-12-07 00:39:11.865 WARN 13237 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=18m22s286ms).
2021-12-07 01:03:48.492 WARN 13237 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=23m5s159ms).
2021-12-07 02:51:52.922 WARN 13237 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h48m4s430ms).
2021-12-07 04:40:11.427 WARN 13237 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h48m18s505ms).
2021-12-07 04:46:27.601 WARN 13237 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=6m16s146ms).
2021-12-07 06:28:46.496 WARN 13237 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h42m18s877ms).
2021-12-07 08:16:57.487 WARN 13237 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h48m11s36ms).
2021-12-07 10:06:29.749 WARN 13237 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h49m32s262ms).
2021-12-07 13:05:00.706 WARN 13237 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=2h58m30s958ms).
2021-12-07 13:45:01.240 WARN 13237 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=40m534ms).
2021-12-07 14:31:31.523 WARN 13237 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Retrograde clock change detected (housekeeper delta=29s849ms), soft-evicting connections from pool.
2021-12-07 18:17:34.472 WARN 13237 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Retrograde clock change detected (housekeeper delta=29s863ms), soft-evicting connections from pool.
2021-12-07 21:28:09.046 INFO 13237 --- [SpringContextShutdownHook] o.s.i.endpoint.EventDrivenConsumer : Removing {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2021-12-07 21:28:09.047 INFO 13237 --- [SpringContextShutdownHook] o.s.i.channel.PublishSubscribeChannel : Channel 'msg.errorChannel' has 0 subscriber(s).
2021-12-07 21:28:09.048 INFO 13237 --- [SpringContextShutdownHook] o.s.i.endpoint.EventDrivenConsumer : stopped bean '_org.springframework.integration.errorLogger'
2021-12-07 21:28:09.055 INFO 13237 --- [SpringContextShutdownHook] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 'taskScheduler'
2021-12-07 21:28:09.090 INFO 13237 --- [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2021-12-07 21:28:09.107 INFO 13237 --- [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2021-12-07 21:28:18.040 [main] INFO com.matrix.md.MessageDemoApplication-Starting MessageDemoApplication using Java 1.8.0_201 on MatrixdeMacBook-Pro.local with PID 18054 (/Users/matrix/code/gitlab/message-demo/message-bus/target/classes started by matrix in /Users/matrix/code/gitlab/message-demo)
2021-12-07 21:28:18.044 [main] INFO com.matrix.md.MessageDemoApplication-No active profile set, falling back to default profiles: default
2021-12-07 21:28:19.332 [main] WARN org.mybatis.spring.mapper.ClassPathMapperScanner-No MyBatis mapper was found in '[com.baomidou.cloud.service.*.mapper*]' package. Please check your configuration.
2021-12-07 21:28:19.435 [main] INFO o.s.i.c.DefaultConfiguringBeanFactoryPostProcessor-No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
2021-12-07 21:28:19.444 [main] INFO o.s.i.c.DefaultConfiguringBeanFactoryPostProcessor-No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created.
2021-12-07 21:28:19.574 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'org.springframework.integration.config.IntegrationManagementConfiguration' of type [org.springframework.integration.config.IntegrationManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-07 21:28:19.579 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration$IntegrationJmxConfiguration' of type [org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration$IntegrationJmxConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-07 21:28:19.585 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration' of type [org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-07 21:28:19.588 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'mbeanServer' of type [com.sun.jmx.mbeanserver.JmxMBeanServer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-07 21:28:19.603 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'integrationChannelResolver' of type [org.springframework.integration.support.channel.BeanFactoryChannelResolver] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-07 21:28:19.605 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'integrationDisposableAutoCreatedBeans' of type [org.springframework.integration.config.annotation.Disposables] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-07 21:28:19.821 [main] INFO o.s.boot.web.embedded.tomcat.TomcatWebServer-Tomcat initialized with port(s): 8180 (http)
2021-12-07 21:28:19.828 [main] INFO org.apache.coyote.http11.Http11NioProtocol-Initializing ProtocolHandler ["http-nio-8180"]
2021-12-07 21:28:19.829 [main] INFO org.apache.catalina.core.StandardService-Starting service [Tomcat]
2021-12-07 21:28:19.829 [main] INFO org.apache.catalina.core.StandardEngine-Starting Servlet engine: [Apache Tomcat/9.0.39]
2021-12-07 21:28:19.891 [main] INFO o.a.c.core.ContainerBase.[Tomcat].[localhost].[/]-Initializing Spring embedded WebApplicationContext
2021-12-07 21:28:19.891 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext-Root WebApplicationContext: initialization completed in 1695 ms
2021-12-07 21:28:20.093 [main] INFO com.zaxxer.hikari.HikariDataSource-HikariPool-1 - Starting...
2021-12-07 21:28:21.333 [main] ERROR com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Exception during pool initialization.
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:358)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:477)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:560)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:158)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:116)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:47)
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.runScripts(DataSourceInitializer.java:202)
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.createSchema(DataSourceInitializer.java:101)
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.afterPropertiesSet(DataSourceInitializerInvoker.java:63)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1847)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1784)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:609)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1235)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveBean(DefaultListableBeanFactory.java:494)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:349)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:342)
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerPostProcessor.postProcessAfterInitialization(DataSourceInitializerPostProcessor.java:51)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:444)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:609)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1367)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1287)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1179)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:571)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1367)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1503)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1401)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:608)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1367)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1287)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1415)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:608)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1367)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1287)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1415)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:608)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:588)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:326)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298)
at com.matrix.md.MessageDemoApplication.main(MessageDemoApplication.java:17)
2021-12-07 21:28:21.339 [main] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext-Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'activeMQUtil': Unsatisfied dependency expressed through field 'specService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'specServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'specMapper' defined in file [/Users/matrix/code/gitlab/message-demo/message-bus/target/classes/com/matrix/md/mapper/SpecMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
2021-12-07 21:28:21.344 [main] INFO org.apache.catalina.core.StandardService-Stopping service [Tomcat]
2021-12-07 21:28:21.356 [main] INFO o.s.b.a.l.ConditionEvaluationReportLoggingListener-
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-12-07 21:28:21.373 [main] ERROR org.springframework.boot.SpringApplication-Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'activeMQUtil': Unsatisfied dependency expressed through field 'specService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'specServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'specMapper' defined in file [/Users/matrix/code/gitlab/message-demo/message-bus/target/classes/com/matrix/md/mapper/SpecMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1415)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:608)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:588)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:326)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298)
at com.matrix.md.MessageDemoApplication.main(MessageDemoApplication.java:17)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'specServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'specMapper' defined in file [/Users/matrix/code/gitlab/message-demo/message-bus/target/classes/com/matrix/md/mapper/SpecMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1415)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:608)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1367)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1287)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
... 20 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'specMapper' defined in file [/Users/matrix/code/gitlab/message-demo/message-bus/target/classes/com/matrix/md/mapper/SpecMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1518)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1401)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:608)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1367)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1287)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
... 33 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1179)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:571)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1367)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1503)
... 44 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:617)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1367)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1287)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789)
... 57 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1788)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:609)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1235)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveBean(DefaultListableBeanFactory.java:494)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:349)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:342)
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerPostProcessor.postProcessAfterInitialization(DataSourceInitializerPostProcessor.java:51)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:444)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:609)
... 67 common frames omitted
Caused by: org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:59)
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.runScripts(DataSourceInitializer.java:202)
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.createSchema(DataSourceInitializer.java:101)
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.afterPropertiesSet(DataSourceInitializerInvoker.java:63)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1847)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1784)
... 81 common frames omitted
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:82)
at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:47)
... 86 common frames omitted
Caused by: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:358)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:477)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:560)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:158)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:116)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
... 87 common frames omitted
2021-12-07 21:28:45.178 [main] INFO com.matrix.md.MessageDemoApplication-Starting MessageDemoApplication using Java 1.8.0_201 on MatrixdeMacBook-Pro.local with PID 18057 (/Users/matrix/code/gitlab/message-demo/message-bus/target/classes started by matrix in /Users/matrix/code/gitlab/message-demo)
2021-12-07 21:28:45.183 [main] INFO com.matrix.md.MessageDemoApplication-No active profile set, falling back to default profiles: default
2021-12-07 21:28:46.285 [main] WARN org.mybatis.spring.mapper.ClassPathMapperScanner-No MyBatis mapper was found in '[com.baomidou.cloud.service.*.mapper*]' package. Please check your configuration.
2021-12-07 21:28:46.406 [main] INFO o.s.i.c.DefaultConfiguringBeanFactoryPostProcessor-No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
2021-12-07 21:28:46.416 [main] INFO o.s.i.c.DefaultConfiguringBeanFactoryPostProcessor-No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created.
2021-12-07 21:28:46.519 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'org.springframework.integration.config.IntegrationManagementConfiguration' of type [org.springframework.integration.config.IntegrationManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-07 21:28:46.523 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration$IntegrationJmxConfiguration' of type [org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration$IntegrationJmxConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-07 21:28:46.529 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration' of type [org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-07 21:28:46.532 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'mbeanServer' of type [com.sun.jmx.mbeanserver.JmxMBeanServer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-07 21:28:46.546 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'integrationChannelResolver' of type [org.springframework.integration.support.channel.BeanFactoryChannelResolver] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-07 21:28:46.547 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'integrationDisposableAutoCreatedBeans' of type [org.springframework.integration.config.annotation.Disposables] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-07 21:28:46.747 [main] INFO o.s.boot.web.embedded.tomcat.TomcatWebServer-Tomcat initialized with port(s): 8180 (http)
2021-12-07 21:28:46.753 [main] INFO org.apache.coyote.http11.Http11NioProtocol-Initializing ProtocolHandler ["http-nio-8180"]
2021-12-07 21:28:46.753 [main] INFO org.apache.catalina.core.StandardService-Starting service [Tomcat]
2021-12-07 21:28:46.754 [main] INFO org.apache.catalina.core.StandardEngine-Starting Servlet engine: [Apache Tomcat/9.0.39]
2021-12-07 21:28:46.810 [main] INFO o.a.c.core.ContainerBase.[Tomcat].[localhost].[/]-Initializing Spring embedded WebApplicationContext
2021-12-07 21:28:46.810 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext-Root WebApplicationContext: initialization completed in 1525 ms
2021-12-07 21:28:46.984 [main] INFO com.zaxxer.hikari.HikariDataSource-HikariPool-1 - Starting...
2021-12-07 21:28:47.243 [main] INFO com.zaxxer.hikari.HikariDataSource-HikariPool-1 - Start completed.
2021-12-07 21:28:48.503 [main] INFO o.s.scheduling.concurrent.ThreadPoolTaskScheduler-Initializing ExecutorService 'taskScheduler'
2021-12-07 21:28:48.705 [main] INFO o.s.integration.monitor.IntegrationMBeanExporter-Registering MessageChannel errorChannel
2021-12-07 21:28:48.762 [main] INFO o.s.integration.monitor.IntegrationMBeanExporter-Registering MessageChannel nullChannel
2021-12-07 21:28:48.769 [main] INFO o.s.integration.monitor.IntegrationMBeanExporter-Registering MessageHandler _org.springframework.integration.errorLogger
2021-12-07 21:28:48.798 [main] INFO o.s.integration.endpoint.EventDrivenConsumer-Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2021-12-07 21:28:48.798 [main] INFO o.s.integration.channel.PublishSubscribeChannel-Channel 'msg.errorChannel' has 1 subscriber(s).
2021-12-07 21:28:48.799 [main] INFO o.s.integration.endpoint.EventDrivenConsumer-started bean '_org.springframework.integration.errorLogger'
2021-12-07 21:28:48.799 [main] INFO org.apache.coyote.http11.Http11NioProtocol-Starting ProtocolHandler ["http-nio-8180"]
2021-12-07 21:28:48.817 [main] INFO o.s.boot.web.embedded.tomcat.TomcatWebServer-Tomcat started on port(s): 8180 (http) with context path ''
2021-12-07 21:28:49.299 [main] INFO com.matrix.md.MessageDemoApplication-Started MessageDemoApplication in 4.647 seconds (JVM running for 5.189)
2021-12-07 21:32:26.679 [http-nio-8180-exec-1] INFO o.a.c.core.ContainerBase.[Tomcat].[localhost].[/]-Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-12-07 21:32:26.680 [http-nio-8180-exec-1] INFO org.springframework.web.servlet.DispatcherServlet-Initializing Servlet 'dispatcherServlet'
2021-12-07 21:32:26.685 [http-nio-8180-exec-1] INFO org.springframework.web.servlet.DispatcherServlet-Completed initialization in 5 ms
2021-12-07 21:34:19.293 [SpringContextShutdownHook] INFO o.s.integration.endpoint.EventDrivenConsumer-Removing {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2021-12-07 21:34:19.294 [SpringContextShutdownHook] INFO o.s.integration.channel.PublishSubscribeChannel-Channel 'msg.errorChannel' has 0 subscriber(s).
2021-12-07 21:34:19.295 [SpringContextShutdownHook] INFO o.s.integration.endpoint.EventDrivenConsumer-stopped bean '_org.springframework.integration.errorLogger'
2021-12-07 21:34:19.296 [SpringContextShutdownHook] INFO o.s.scheduling.concurrent.ThreadPoolTaskScheduler-Shutting down ExecutorService 'taskScheduler'
2021-12-07 21:34:19.303 [SpringContextShutdownHook] INFO com.zaxxer.hikari.HikariDataSource-HikariPool-1 - Shutdown initiated...
2021-12-07 21:34:19.310 [SpringContextShutdownHook] INFO com.zaxxer.hikari.HikariDataSource-HikariPool-1 - Shutdown completed.
2021-12-07 21:34:21.977 [main] INFO com.matrix.md.MessageDemoApplication-Starting MessageDemoApplication using Java 1.8.0_201 on MatrixdeMacBook-Pro.local with PID 18108 (/Users/matrix/code/gitlab/message-demo/message-bus/target/classes started by matrix in /Users/matrix/code/gitlab/message-demo)
2021-12-07 21:34:21.980 [main] INFO com.matrix.md.MessageDemoApplication-No active profile set, falling back to default profiles: default
2021-12-07 21:34:22.958 [main] WARN org.mybatis.spring.mapper.ClassPathMapperScanner-No MyBatis mapper was found in '[com.baomidou.cloud.service.*.mapper*]' package. Please check your configuration.
2021-12-07 21:34:23.033 [main] INFO o.s.i.c.DefaultConfiguringBeanFactoryPostProcessor-No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
2021-12-07 21:34:23.040 [main] INFO o.s.i.c.DefaultConfiguringBeanFactoryPostProcessor-No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created.
2021-12-07 21:34:23.168 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'org.springframework.integration.config.IntegrationManagementConfiguration' of type [org.springframework.integration.config.IntegrationManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-07 21:34:23.172 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration$IntegrationJmxConfiguration' of type [org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration$IntegrationJmxConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-07 21:34:23.177 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration' of type [org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-07 21:34:23.180 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'mbeanServer' of type [com.sun.jmx.mbeanserver.JmxMBeanServer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-07 21:34:23.194 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'integrationChannelResolver' of type [org.springframework.integration.support.channel.BeanFactoryChannelResolver] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-07 21:34:23.196 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'integrationDisposableAutoCreatedBeans' of type [org.springframework.integration.config.annotation.Disposables] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-07 21:34:23.378 [main] INFO o.s.boot.web.embedded.tomcat.TomcatWebServer-Tomcat initialized with port(s): 8180 (http)
2021-12-07 21:34:23.389 [main] INFO org.apache.coyote.http11.Http11NioProtocol-Initializing ProtocolHandler ["http-nio-8180"]
2021-12-07 21:34:23.389 [main] INFO org.apache.catalina.core.StandardService-Starting service [Tomcat]
2021-12-07 21:34:23.389 [main] INFO org.apache.catalina.core.StandardEngine-Starting Servlet engine: [Apache Tomcat/9.0.39]
2021-12-07 21:34:23.456 [main] INFO o.a.c.core.ContainerBase.[Tomcat].[localhost].[/]-Initializing Spring embedded WebApplicationContext
2021-12-07 21:34:23.456 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext-Root WebApplicationContext: initialization completed in 1430 ms
2021-12-07 21:34:23.577 [main] INFO com.zaxxer.hikari.HikariDataSource-HikariPool-1 - Starting...
2021-12-07 21:34:23.792 [main] INFO com.zaxxer.hikari.HikariDataSource-HikariPool-1 - Start completed.
2021-12-07 21:34:24.815 [main] INFO o.s.scheduling.concurrent.ThreadPoolTaskScheduler-Initializing ExecutorService 'taskScheduler'
2021-12-07 21:34:24.997 [main] INFO o.s.integration.monitor.IntegrationMBeanExporter-Registering MessageChannel errorChannel
2021-12-07 21:34:25.038 [main] INFO o.s.integration.monitor.IntegrationMBeanExporter-Registering MessageChannel nullChannel
2021-12-07 21:34:25.047 [main] INFO o.s.integration.monitor.IntegrationMBeanExporter-Registering MessageHandler _org.springframework.integration.errorLogger
2021-12-07 21:34:25.083 [main] INFO o.s.integration.endpoint.EventDrivenConsumer-Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2021-12-07 21:34:25.084 [main] INFO o.s.integration.channel.PublishSubscribeChannel-Channel 'msg.errorChannel' has 1 subscriber(s).
2021-12-07 21:34:25.084 [main] INFO o.s.integration.endpoint.EventDrivenConsumer-started bean '_org.springframework.integration.errorLogger'
2021-12-07 21:34:25.084 [main] INFO org.apache.coyote.http11.Http11NioProtocol-Starting ProtocolHandler ["http-nio-8180"]
2021-12-07 21:34:25.102 [main] INFO o.s.boot.web.embedded.tomcat.TomcatWebServer-Tomcat started on port(s): 8180 (http) with context path ''
2021-12-07 21:34:25.556 [main] INFO com.matrix.md.MessageDemoApplication-Started MessageDemoApplication in 4.06 seconds (JVM running for 4.64)
2021-12-07 21:34:43.235 [http-nio-8180-exec-1] INFO o.a.c.core.ContainerBase.[Tomcat].[localhost].[/]-Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-12-07 21:34:43.236 [http-nio-8180-exec-1] INFO org.springframework.web.servlet.DispatcherServlet-Initializing Servlet 'dispatcherServlet'
2021-12-07 21:34:43.237 [http-nio-8180-exec-1] INFO org.springframework.web.servlet.DispatcherServlet-Completed initialization in 1 ms
2021-12-07 23:34:55.173 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Retrograde clock change detected (housekeeper delta=29s819ms), soft-evicting connections from pool.
2021-12-08 03:34:27.094 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=30m28s927ms).
2021-12-08 03:58:16.180 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=17m48s994ms).
2021-12-08 04:17:07.525 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=18m21s342ms).
2021-12-08 04:36:52.549 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=19m15s21ms).
2021-12-08 04:58:48.238 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=16m55s620ms).
2021-12-08 06:04:39.061 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h5m50s823ms).
2021-12-08 07:01:48.975 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=56m39s880ms).
2021-12-08 07:58:45.407 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=56m26s427ms).
2021-12-08 09:03:14.411 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h3m58s999ms).
2021-12-08 10:08:30.456 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h5m16s45ms).
2021-12-08 13:14:49.222 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=25m14s240ms).
2021-12-08 14:16:09.684 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h1m20s462ms).
2021-12-08 14:20:41.841 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=4m32s157ms).
2021-12-08 15:58:18.215 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=13m4s131ms).
2021-12-08 15:59:30.316 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1m12s101ms).
2021-12-08 16:06:51.147 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=6m50s824ms).
2021-12-08 16:22:49.090 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Retrograde clock change detected (housekeeper delta=27s830ms), soft-evicting connections from pool.
2021-12-08 18:27:25.549 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=28m3s617ms).
2021-12-08 18:28:47.409 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=51s851ms).
2021-12-08 18:33:34.077 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=4m46s668ms).
2021-12-08 18:50:45.280 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=17m11s203ms).
2021-12-09 01:03:49.261 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Retrograde clock change detected (housekeeper delta=29s864ms), soft-evicting connections from pool.
2021-12-09 01:04:41.979 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=52s721ms).
2021-12-09 01:35:10.862 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=30m28s883ms).
2021-12-09 03:17:42.943 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h33m2s).
2021-12-09 04:43:48.751 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h25m35s897ms).
2021-12-09 05:49:14.589 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h4m55s815ms).
2021-12-09 07:02:18.061 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h12m33s470ms).
2021-12-09 08:30:56.274 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h28m8s194ms).
2021-12-09 10:01:11.502 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h30m15s228ms).
2021-12-09 11:01:40.528 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=59m59s53ms).
2021-12-09 13:00:38.164 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=59m27s32ms).
2021-12-09 13:08:43.629 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=8m5s464ms).
2021-12-09 14:04:01.353 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=53m17s684ms).
2021-12-09 14:21:06.291 [SpringContextShutdownHook] INFO o.s.integration.endpoint.EventDrivenConsumer-Removing {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2021-12-09 14:21:06.294 [SpringContextShutdownHook] INFO o.s.integration.channel.PublishSubscribeChannel-Channel 'msg.errorChannel' has 0 subscriber(s).
2021-12-09 14:21:06.295 [SpringContextShutdownHook] INFO o.s.integration.endpoint.EventDrivenConsumer-stopped bean '_org.springframework.integration.errorLogger'
2021-12-09 14:21:06.304 [SpringContextShutdownHook] INFO o.s.scheduling.concurrent.ThreadPoolTaskScheduler-Shutting down ExecutorService 'taskScheduler'
2021-12-09 14:21:06.326 [SpringContextShutdownHook] INFO com.zaxxer.hikari.HikariDataSource-HikariPool-1 - Shutdown initiated...
2021-12-09 14:21:06.334 [SpringContextShutdownHook] INFO com.zaxxer.hikari.HikariDataSource-HikariPool-1 - Shutdown completed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
2022-03-18 02:21:13.201 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=25m59s742ms).
2022-03-18 03:50:07.643 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h28m54s447ms).
2022-03-18 07:05:32.967 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=3h15m25s323ms).
2022-03-18 09:13:17.392 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=2h7m44s426ms).
2022-03-18 11:30:41.502 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=2h17m24s109ms).
2022-03-18 13:30:40.238 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h59m58s736ms).
2022-03-18 13:46:33.907 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=15m53s670ms).
2022-03-18 13:49:44.744 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=2m10s820ms).
2022-03-18 18:27:50.107 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=2m32s771ms).
2022-03-18 20:25:43.924 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h57m53s818ms).
2022-03-18 23:28:52.757 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=3h3m8s830ms).
2022-03-19 00:08:54.239 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=39m31s471ms).
2022-03-19 00:43:42.789 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=8m47s950ms).
2022-03-19 00:49:28.786 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=5m45s999ms).
2022-03-19 02:24:59.153 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=17m59s250ms).
2022-03-19 02:38:54.788 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=7m25s520ms).
2022-03-19 06:06:38.229 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=16m10s681ms).
2022-03-19 07:24:11.816 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=17m2s750ms).
2022-03-19 08:44:32.085 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=16m49s425ms).
2022-03-19 10:01:34.946 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1h16m2s824ms).
2022-03-19 10:37:24.012 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=35m49s67ms).
2022-03-19 10:51:30.991 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=14m6s979ms).
2022-03-19 12:52:02.258 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=2h31s267ms).
2022-03-19 13:15:56.284 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool-HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=23m54s26ms).
2022-05-07 16:16:44.439 [main] INFO com.matrix.md.MessageDemoApplication-Starting MessageDemoApplication using Java 1.8.0_201 on MacBook-Pro.local with PID 43294 (/Users/matrix/code/gitlab/message-demo/message-bus/target/classes started by matrix in /Users/matrix/code/gitlab/message-demo)
2022-05-07 16:16:44.441 [main] INFO com.matrix.md.MessageDemoApplication-The following profiles are active: dev
2022-05-07 16:16:45.777 [main] WARN org.mybatis.spring.mapper.ClassPathMapperScanner-No MyBatis mapper was found in '[com.baomidou.cloud.service.*.mapper*]' package. Please check your configuration.
2022-05-07 16:16:45.982 [main] INFO o.s.i.c.DefaultConfiguringBeanFactoryPostProcessor-No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
2022-05-07 16:16:45.993 [main] INFO o.s.i.c.DefaultConfiguringBeanFactoryPostProcessor-No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created.
2022-05-07 16:16:46.173 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'org.springframework.integration.config.IntegrationManagementConfiguration' of type [org.springframework.integration.config.IntegrationManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-05-07 16:16:46.180 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration$IntegrationJmxConfiguration' of type [org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration$IntegrationJmxConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-05-07 16:16:46.185 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration' of type [org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-05-07 16:16:46.189 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'mbeanServer' of type [com.sun.jmx.mbeanserver.JmxMBeanServer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-05-07 16:16:46.218 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'integrationChannelResolver' of type [org.springframework.integration.support.channel.BeanFactoryChannelResolver] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-05-07 16:16:46.221 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker-Bean 'integrationDisposableAutoCreatedBeans' of type [org.springframework.integration.config.annotation.Disposables] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-05-07 16:16:46.458 [main] INFO o.s.boot.web.embedded.tomcat.TomcatWebServer-Tomcat initialized with port(s): 8180 (http)
2022-05-07 16:16:46.466 [main] INFO org.apache.coyote.http11.Http11NioProtocol-Initializing ProtocolHandler ["http-nio-8180"]
2022-05-07 16:16:46.466 [main] INFO org.apache.catalina.core.StandardService-Starting service [Tomcat]
2022-05-07 16:16:46.467 [main] INFO org.apache.catalina.core.StandardEngine-Starting Servlet engine: [Apache Tomcat/9.0.39]
2022-05-07 16:16:46.536 [main] INFO o.a.c.core.ContainerBase.[Tomcat].[localhost].[/]-Initializing Spring embedded WebApplicationContext
2022-05-07 16:16:46.537 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext-Root WebApplicationContext: initialization completed in 2023 ms
2022-05-07 16:16:46.763 [main] INFO com.zaxxer.hikari.HikariDataSource-HikariPool-1 - Starting...
2022-05-07 16:16:47.055 [main] INFO com.zaxxer.hikari.HikariDataSource-HikariPool-1 - Start completed.
2022-05-07 16:16:48.597 [main] INFO o.s.scheduling.concurrent.ThreadPoolTaskScheduler-Initializing ExecutorService 'taskScheduler'
2022-05-07 16:16:48.880 [main] INFO o.s.integration.monitor.IntegrationMBeanExporter-Registering MessageChannel errorChannel
2022-05-07 16:16:48.947 [main] INFO o.s.integration.monitor.IntegrationMBeanExporter-Registering MessageChannel nullChannel
2022-05-07 16:16:48.972 [main] INFO o.s.integration.monitor.IntegrationMBeanExporter-Registering MessageHandler _org.springframework.integration.errorLogger
2022-05-07 16:16:49.018 [main] INFO o.s.integration.endpoint.EventDrivenConsumer-Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2022-05-07 16:16:49.018 [main] INFO o.s.integration.channel.PublishSubscribeChannel-Channel 'message-demo.errorChannel' has 1 subscriber(s).
2022-05-07 16:16:49.019 [main] INFO o.s.integration.endpoint.EventDrivenConsumer-started bean '_org.springframework.integration.errorLogger'
2022-05-07 16:16:49.019 [main] INFO org.apache.coyote.http11.Http11NioProtocol-Starting ProtocolHandler ["http-nio-8180"]
2022-05-07 16:16:49.038 [main] INFO o.s.boot.web.embedded.tomcat.TomcatWebServer-Tomcat started on port(s): 8180 (http) with context path ''
2022-05-07 16:16:49.896 [main] INFO com.matrix.md.MessageDemoApplication-Started MessageDemoApplication in 5.927 seconds (JVM running for 6.516)
2022-05-07 16:17:00.169 [http-nio-8180-exec-1] INFO o.a.c.core.ContainerBase.[Tomcat].[localhost].[/]-Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-05-07 16:17:00.170 [http-nio-8180-exec-1] INFO org.springframework.web.servlet.DispatcherServlet-Initializing Servlet 'dispatcherServlet'
2022-05-07 16:17:00.176 [http-nio-8180-exec-1] INFO org.springframework.web.servlet.DispatcherServlet-Completed initialization in 6 ms
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.matirx</groupId>
<artifactId>mail-163</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>mail-163</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.78</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package com.matirx.mail.gmail;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
public class SinaMailApplication {
public static void main(String[] args) {
SpringApplication.run(SinaMailApplication.class, args);
}
}
package com.matirx.mail.gmail.config;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.jms.core.JmsTemplate;
import javax.jms.ConnectionFactory;
/**
* JmsConfig.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/4 at 4:48 下午
*/
@Configuration
public class JmsConfig {
@Autowired
private Environment env;
@Bean
public ConnectionFactory connectionFactory() {
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL(env.getProperty("spring.activemq.broker-url"));
connectionFactory.setUserName(env.getProperty("spring.activemq.user"));
connectionFactory.setPassword(env.getProperty("spring.activemq.password"));
return connectionFactory;
}
@Bean
public JmsTemplate genJmsTemplate() {
return new JmsTemplate(connectionFactory());
}
@Bean
public JmsMessagingTemplate jmsMessageTemplate() {
return new JmsMessagingTemplate(connectionFactory());
}
}
package com.matirx.mail.gmail.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* SpringFoxConfig.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/22 at 5:28 下午
*/
@Configuration
@EnableSwagger2
public class SpringFoxConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
package com.matirx.mail.gmail.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
/**
* WebMvcConfigConfig.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/22 at 5:30 下午
*/
@Configuration
public class WebMvcConfigConfig extends WebMvcConfigurationSupport {
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
super.addResourceHandlers(registry);
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
package com.matirx.mail.gmail.consumer;
import com.alibaba.fastjson.JSON;
import com.matirx.mail.gmail.entity.MailInfo;
import com.matirx.mail.gmail.service.MailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Component;
/**
* SendConsumer. 邮件发送接口的消息消费服务
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/30 at 6:14 下午
* Suffering is the most powerful teacher of life.
*/
@Slf4j
@Component
public class SendConsumer {
private final String baseEndpoints = "x001x002.mail.send";
@Autowired
private MailService mailService;
/**
* 转发到邮件服务
* @param text 消息体
*/
@JmsListener(destination = baseEndpoints)
public void receiveQueue(String text) {
MailInfo mailInfo = JSON.parseObject(text, MailInfo.class);
//1.调用服务发送邮件
mailService.sendMail(mailInfo);
//2.log
log.info("[Sina mail] 邮件发送完毕,送至 {} ",mailInfo.getMailAddress());
}
}
package com.matirx.mail.gmail.controller;
import com.matirx.mail.gmail.service.MailService;
import io.swagger.annotations.Api;
import com.matirx.mail.gmail.entity.MailInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* MailController.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 1:43 上午
* Suffering is the most powerful teacher of life.
*/
@RestController
@RequestMapping("/mail")
@Api(tags = "邮件接口")
public class MailController {
@Autowired
private MailService mailService;
@PostMapping("/send")
public ResponseEntity<String> sendMail(@RequestBody MailInfo mailInfo) {
mailService.sendMail(mailInfo);
return ResponseEntity.ok("发送成功");
}
}
package com.matirx.mail.gmail.entity;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;
/**
* CustomBeans.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 1:03 上午
* Suffering is the most powerful teacher of life.
*/
@Configuration
public class CustomBeans {
@Bean
public RestTemplate restTemplate(){
return new RestTemplate();
}
@Bean
public ObjectMapper objectMapper(){
return new ObjectMapper();
}
}
package com.matirx.mail.gmail.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* MailInfo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 1:44 上午
* Suffering is the most powerful teacher of life.
*/
@Data
@ApiModel("邮件信息体")
public class MailInfo {
@ApiModelProperty(value = "邮件标题",example = "QQ邮件的标题")
private String title;
@ApiModelProperty(value = "发送的邮件终点地址",example = "xhyrzldf@gmail.com")
private String mailAddress;
@ApiModelProperty(value = "发送的邮件内容",example = "This is a test mail")
private String content;
}
package com.matirx.mail.gmail.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* ServerInfo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 12:43 上午
* Suffering is the most powerful teacher of life.
*/
@Data
@ApiModel("服务器信息,模拟服务注册")
public class ServerInfo {
@ApiModelProperty("组件编号")
private String comNumber;
@ApiModelProperty("组件地址")
private String comAddress;
}
package com.matirx.mail.gmail.service;
import com.matirx.mail.gmail.entity.MailInfo;
/**
* MailService.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 1:34 上午
* Suffering is the most powerful teacher of life.
*/
public interface MailService {
/**
* 向指定地址以Gmail邮箱的形式发送邮件
* @param mailInfo 邮件信息
*/
void sendMail(MailInfo mailInfo);
}
package com.matirx.mail.gmail.service;
import com.matirx.mail.gmail.entity.MailInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Service;
/**
* MailServiceImpl.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 1:41 上午
* Suffering is the most powerful teacher of life.
*/
@Service
@Slf4j
public class MailServiceImpl implements MailService {
@Autowired
JavaMailSenderImpl mailSender;
/**
* 向指定地址以Gmail邮箱的形式发送邮件
*/
@Override
public void sendMail(MailInfo mailInfo) {
SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setSubject(mailInfo.getTitle() + " - 来自新浪邮箱组件提供");
mailMessage.setText(mailInfo.getContent());
mailMessage.setTo(mailInfo.getMailAddress());
mailMessage.setFrom("matrixldf@sina.com");
log.info("[Sina mail] 准备发送邮件-发送数据 {}", mailInfo);
mailSender.send(mailMessage);
}
}
package com.matirx.mail.gmail.tasks;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
/**
* ScheduledTasks.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 1:05 上午
* Suffering is the most powerful teacher of life.
*/
@Component
@Slf4j
public class ScheduledTasks {
@Autowired
private RestTemplate restTemplate;
@Autowired
private ObjectMapper objectMapper;
private String registerUrl = "http://localhost:8180/server/register";
/**
* 每30秒进行一次心跳
*/
@Scheduled(initialDelay = 5000, fixedRate = 30000)
public void registerAndHeartBeat() {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
ObjectNode serverNode = objectMapper.createObjectNode();
serverNode.put("comNumber", "x001x001");
serverNode.put("comAddress", "127.0.0.1");
HttpEntity<String> request = new HttpEntity<>(serverNode.toString(), headers);
String result = null;
try {
result = restTemplate.postForObject(registerUrl, request, String.class);
} catch (RestClientException e) {
log.debug("[Gmail] 没有找到消息总线服务器...");
}
log.info("register success , response = {}", result);
}
}
server.port=8181
spring.mail.username=matrixldf@sina.com
spring.mail.password=55d82e9c99f5c16c
spring.mail.host=smtp.sina.com
#开启加密验证
spring.mail.properties.mail.smtp.ssl.enable=true
# ActiveMQ
spring.activemq.broker-url=tcp://127.0.0.1:61616
spring.activemq.user=admin
spring.activemq.password=admin
spring.activemq.pool.enabled=true
spring.activemq.pool.max-connections=100
# Log
logging.file.name=log/mail-sina.log
package com.matirx.mail.gmail;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class MailGmailApplicationTests {
@Test
void contextLoads() {
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.matrix</groupId>
<artifactId>mail-qq</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>mail-qq</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.78</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package com.matrix.mail.qq;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
public class MailQqApplication {
public static void main(String[] args) {
SpringApplication.run(MailQqApplication.class, args);
}
}
package com.matrix.mail.qq.config;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.jms.core.JmsTemplate;
import javax.jms.ConnectionFactory;
/**
* JmsConfig.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/4 at 4:48 下午
*/
@Configuration
public class JmsConfig {
@Autowired
private Environment env;
@Bean
public ConnectionFactory connectionFactory() {
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL(env.getProperty("spring.activemq.broker-url"));
connectionFactory.setUserName(env.getProperty("spring.activemq.user"));
connectionFactory.setPassword(env.getProperty("spring.activemq.password"));
return connectionFactory;
}
@Bean
public JmsTemplate genJmsTemplate() {
return new JmsTemplate(connectionFactory());
}
@Bean
public JmsMessagingTemplate jmsMessageTemplate() {
return new JmsMessagingTemplate(connectionFactory());
}
}
package com.matrix.mail.qq.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* SpringFoxConfig.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/22 at 5:28 下午
*/
@Configuration
@EnableSwagger2
public class SpringFoxConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
package com.matrix.mail.qq.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
/**
* WebMvcConfigConfig.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/22 at 5:30 下午
*/
@Configuration
public class WebMvcConfigConfig extends WebMvcConfigurationSupport {
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
super.addResourceHandlers(registry);
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
package com.matrix.mail.qq.consumer;
import com.alibaba.fastjson.JSON;
import com.matrix.mail.qq.entity.MailInfo;
import com.matrix.mail.qq.service.MailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
/**
* SendConsumer. 邮件发送接口的消息消费服务
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/30 at 6:14 下午
* Suffering is the most powerful teacher of life.
*/
@Slf4j
@Component
public class SendConsumer {
private final String baseEndpoints = "x001x001.mail.send";
@Autowired
private MailService mailService;
/**
* 转发到邮件服务
* @param text 消息体
*/
@JmsListener(destination = baseEndpoints)
public void receiveQueue(String text) {
MailInfo mailInfo = JSON.parseObject(text, MailInfo.class);
//1.调用服务发送邮件
mailService.sendMail(mailInfo);
//2.log
log.info("[QQmail] 邮件发送完毕,送至 {} ",mailInfo.getMailAddress());
}
}
package com.matrix.mail.qq.controller;
import com.matrix.mail.qq.entity.MailInfo;
import com.matrix.mail.qq.service.MailService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* MailController.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 1:43 上午
* Suffering is the most powerful teacher of life.
*/
@RestController
@RequestMapping("/mail")
@Api(tags = "邮件接口")
public class MailController {
@Autowired
private MailService mailService;
@PostMapping("/send")
public ResponseEntity<String> sendMail(@RequestBody MailInfo mailInfo) {
mailService.sendMail(mailInfo);
return ResponseEntity.ok("mail send success to " + mailInfo.getMailAddress());
}
}
package com.matrix.mail.qq.entity;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
/**
* CustomBeans.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 1:03 上午
* Suffering is the most powerful teacher of life.
*/
@Configuration
public class CustomBeans {
@Bean
public RestTemplate restTemplate(){
return new RestTemplate();
}
@Bean
public ObjectMapper objectMapper(){
return new ObjectMapper();
}
}
package com.matrix.mail.qq.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* MailInfo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 1:44 上午
* Suffering is the most powerful teacher of life.
*/
@Data
@ApiModel("邮件信息体")
public class MailInfo {
@ApiModelProperty(value = "邮件标题",example = "QQ邮件的标题")
private String title;
@ApiModelProperty(value = "发送的邮件终点地址",example = "xhyrzldf@gmail.com")
private String mailAddress;
@ApiModelProperty(value = "发送的邮件内容",example = "This is a test mail")
private String content;
}
package com.matrix.mail.qq.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* ServerInfo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 12:43 上午
* Suffering is the most powerful teacher of life.
*/
@Data
@ApiModel("服务器信息,模拟服务注册")
public class ServerInfo {
@ApiModelProperty("组件编号")
private String comNumber;
@ApiModelProperty("组件地址")
private String comAddress;
}
package com.matrix.mail.qq.service;
import com.matrix.mail.qq.entity.MailInfo;
import org.springframework.stereotype.Service;
/**
* MailService.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 1:34 上午
* Suffering is the most powerful teacher of life.
*/
public interface MailService {
/**
* 向指定地址以QQ邮箱的形式发送邮件
* @param mailInfo
*/
void sendMail(MailInfo mailInfo);
}
package com.matrix.mail.qq.service;
import com.matrix.mail.qq.entity.MailInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Service;
/**
* MailServiceImpl.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 1:41 上午
* Suffering is the most powerful teacher of life.
*/
@Slf4j
@Service
public class MailServiceImpl implements MailService {
@Autowired
JavaMailSenderImpl mailSender;
/**
* 向指定地址以Gmail邮箱的形式发送邮件
*/
@Override
public void sendMail(MailInfo mailInfo) {
SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setSubject(mailInfo.getTitle()+" - 来自QQ邮箱组件提供");
mailMessage.setText(mailInfo.getContent());
mailMessage.setTo(mailInfo.getMailAddress());
mailMessage.setFrom("296796683@qq.com");
log.info("[QQ mail] 准备发送邮件-发送数据 {}", mailInfo);
mailSender.send(mailMessage);
}
}
package com.matrix.mail.qq.tasks;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
/**
* ScheduledTasks.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 1:05 上午
* Suffering is the most powerful teacher of life.
*/
@Component
@Slf4j
public class ScheduledTasks {
@Autowired
private RestTemplate restTemplate;
@Autowired
private ObjectMapper objectMapper;
private String registerUrl = "http://localhost:8180/server/register";
/**
* 每30秒进行一次心跳
*/
@Scheduled(initialDelay = 5000, fixedRate = 30000)
public void registerAndHeartBeat() {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
ObjectNode serverNode = objectMapper.createObjectNode();
serverNode.put("comNumber", "x001x002");
serverNode.put("comAddress", "127.0.0.1");
HttpEntity<String> request = new HttpEntity<>(serverNode.toString(), headers);
String result = null;
try {
result = restTemplate.postForObject(registerUrl, request, String.class);
} catch (RestClientException e) {
log.debug("[QQmail] 没有找到消息总线服务器...");
}
log.info("register success , response = {}", result);
}
}
package consumer;
import com.alibaba.fastjson.JSON;
import com.matrix.mail.qq.entity.MailInfo;
import com.matrix.mail.qq.service.MailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
/**
* SendConsumer. 邮件发送接口的消息消费服务
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/30 at 6:14 下午
* Suffering is the most powerful teacher of life.
*/
@Slf4j
@Component
public class SendConsumer {
private final String baseEndpoints = "x001x001.mail.send";
@Autowired
private MailService mailService;
/**
* 转发到邮件服务
* @param text 消息体
*/
@JmsListener(destination = baseEndpoints)
public void receiveQueue(String text) {
MailInfo mailInfo = JSON.parseObject(text, MailInfo.class);
//1.调用服务发送邮件
mailService.sendMail(mailInfo);
//2.log
log.info("[QQmail] 邮件发送完毕,送至 {} ",mailInfo.getMailAddress());
}
}
server.port=8182
# mail
spring.mail.username=296796683@qq.com
spring.mail.password=sbtzhiccqkfabhhe
spring.mail.host=smtp.qq.com
#开启加密验证
spring.mail.properties.mail.smtp.ssl.enable=true
# ActiveMQ
spring.activemq.broker-url=tcp://127.0.0.1:61616
spring.activemq.user=admin
spring.activemq.password=admin
spring.activemq.pool.enabled=true
spring.activemq.pool.max-connections=100
# Log
logging.file.name=log/mail-qq.log
package com.matrix.mail.qq;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class MailQqApplicationTests {
@Test
void contextLoads() {
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.matrix</groupId>
<artifactId>message-bus</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>message-bus</name>
<description>Demo project for Spring Boot1</description>
<properties>
<java.version>1.8</java.version>
</properties>
<profiles>
<!--开发环境-->
<profile>
<id>dev</id>
<properties>
<activatedProperties>dev</activatedProperties>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!--生产环境-->
<profile>
<id>prod</id>
<properties>
<activatedProperties>prod</activatedProperties>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.78</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.13.0</version>
</dependency>
<!-- spring-boot-starter-integration -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-integration</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-jmx</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>2.4.5</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.3.4</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package com.matrix.md;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
/**
* @author matrix
*/
@SpringBootApplication
@MapperScan("com.matrix.md.mapper")
@EnableScheduling
public class MessageDemoApplication {
public static void main(String[] args) {
SpringApplication.run(MessageDemoApplication.class, args);
}
}
package com.matrix.md.bean;
import org.modelmapper.ModelMapper;
import org.modelmapper.convention.MatchingStrategies;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
/**
* BeanHelper.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/1 at 1:32 下午
* Suffering is the most powerful teacher of life.
*/
@Component
public class BeanHelper {
private static ModelMapper mapper = new ModelMapper();
static {
mapper.getConfiguration().setAmbiguityIgnored(true);
//设置为严格匹配
mapper.getConfiguration().setFullTypeMatchingRequired(true);
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
}
public static ModelMapper getUserMapper() {
return mapper;
}
@Bean
public ModelMapper initModelMapper() {
return mapper;
}
}
package com.matrix.md.bean;
import com.matrix.md.entity.vo.ServerInfo;
import lombok.Data;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* ShardingData.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 12:37 上午
* Suffering is the most powerful teacher of life.
*/
@Data
@Component
public class ShardingData {
/**
* key = 组件编号 , value = 组件实际地址
*/
private Map<String, String> componentAddress = new HashMap<>();
public Map<String, String> registerAddress(ServerInfo serverInfo) {
componentAddress.put(serverInfo.getComNumber(), serverInfo.getComAddress());
return componentAddress;
}
}
package com.matrix.md.config;
import com.matrix.md.entity.vo.MessageMetrics;
import com.matrix.md.service.SpecService;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.broker.jmx.BrokerViewMBean;
import org.apache.activemq.broker.jmx.QueueViewMBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.management.MBeanServerConnection;
import javax.management.MBeanServerInvocationHandler;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* ActiveMQUtil.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 2:39 AM
* Suffering is the most powerful teacher of life.
*/
@Component
@Slf4j
public class ActiveMQUtil {
@Autowired
private ActivemqUtilConfig activemqUtilConfig;
@Autowired
private SpecService specService;
public Map<String, MessageMetrics> getQueueInfos() {
Map<String, MessageMetrics> queueMap = new HashMap<>();
BrokerViewMBean mBean = null;
MBeanServerConnection connection = null;
try {
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + activemqUtilConfig.getConnectorIp() + ":" + activemqUtilConfig.getConnectorPort() + activemqUtilConfig.getConnectorPath());
JMXConnector connector = JMXConnectorFactory.connect(url);
connector.connect();
connection = connector.getMBeanServerConnection();
ObjectName name = new ObjectName(activemqUtilConfig.getJmxDomain() + ":brokerName=" + activemqUtilConfig.getBrokerName() + ",type=Broker");
mBean = MBeanServerInvocationHandler.newProxyInstance(connection, name, BrokerViewMBean.class, true);
} catch (IOException | MalformedObjectNameException e) {
log.error("ActiveMQUtil.getAllQueueSize", e);
}
if (mBean != null) {
for (ObjectName queueName : mBean.getQueues()) {
QueueViewMBean qm = MBeanServerInvocationHandler.newProxyInstance(connection, queueName, QueueViewMBean.class, true);
if (qm.getName().contains("mail")) {
String name = "";
String processName = "";
if ("mail".equals(qm.getName())) {
name = "邮件规范";
Long comId = specService.getById(1).getCurrentComId();
if (comId == 1) {
processName = "qq邮箱组件";
}
if (comId == 2) {
processName = "新浪邮箱组件";
}
}
if ("x001x001.mail.send".equals(qm.getName())) {
name = "邮件规范子组件";
processName = "qq邮箱组件";
}
if ("x001x002.mail.send".equals(qm.getName())) {
name = "邮件规范子组件";
processName = "新浪邮箱组件";
}
MessageMetrics metrics = new MessageMetrics(
name, processName, "文本数据",qm.getName(), qm.getBlockedSends(),
qm.getConsumerCount(), qm.getEnqueueCount(), qm.getDequeueCount(),
qm.getMaxEnqueueTime(), qm.getMinEnqueueTime(), qm.getAverageEnqueueTime(),
qm.getMaxMessageSize(), qm.getMinMessageSize(), qm.getAverageMessageSize()
);
queueMap.put(qm.getName(), metrics);
}
}
}
return queueMap;
}
}
package com.matrix.md.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* ActivemqUtilConfig.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 2:37 AM
* Suffering is the most powerful teacher of life.
*/
@Component
@Data
@ConfigurationProperties(prefix = "active")
public class ActivemqUtilConfig {
private String connectorPort;
private String connectorPath;
private String jmxDomain;
private String connectorIp;
private String brokerName;
}
package com.matrix.md.config;
import org.springframework.context.annotation.Configuration;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* 配置跨域
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 2:33 PM
* Suffering is the most powerful teacher of life.
*/
@Configuration
public class CorsConfig implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
Filter.super.init(filterConfig);
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) servletResponse;
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE, PATCH");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers", "Origin, Content-Type, Accept");
response.setHeader("Access-Control-Expose-Headers", "Location");
filterChain.doFilter(servletRequest, servletResponse);
}
@Override
public void destroy() {
Filter.super.destroy();
}
}
package com.matrix.md.config;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.jms.core.JmsTemplate;
import javax.jms.ConnectionFactory;
/**
* JmsConfig.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/4 at 4:48 下午
*/
@Configuration
public class JmsConfig {
@Autowired
private Environment env;
@Bean
public ConnectionFactory connectionFactory() {
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL(env.getProperty("spring.activemq.broker-url"));
connectionFactory.setUserName(env.getProperty("spring.activemq.user"));
connectionFactory.setPassword(env.getProperty("spring.activemq.password"));
return connectionFactory;
}
@Bean
public JmsTemplate genJmsTemplate() {
return new JmsTemplate(connectionFactory());
}
@Bean
public JmsMessagingTemplate jmsMessageTemplate() {
return new JmsMessagingTemplate(connectionFactory());
}
}
package com.matrix.md.config;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* LocalDateTimeSerializerConfig.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/1 at 12:09 下午
* Suffering is the most powerful teacher of life.
*/
@Configuration
public class LocalDateTimeSerializerConfig {
@Value("${spring.jackson.date-format:yyyy-MM-dd HH:mm:ss}")
private String pattern;
@Bean
public LocalDateTimeSerializer localDateTimeDeserializer() {
return new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(pattern));
}
@Bean
public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
return builder -> builder.serializerByType(LocalDateTime.class, localDateTimeDeserializer());
}
}
package com.matrix.md.config;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
/**
* MetaFieldHandler.
* 元数据处理器,用于处理自动填充的字段
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/22 at 7:52 下午
*/
@Component
public class MetaFieldHandler implements MetaObjectHandler {
/**
* 创建时设置创建时间
* @param metaObject 数据库原始对象
*/
@Override
public void insertFill(MetaObject metaObject) {
this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());
this.strictInsertFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
}
/**
* 更新时设置更新时间
* @param metaObject 数据库原始对象
*/
@Override
public void updateFill(MetaObject metaObject) {
this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
}
}
package com.matrix.md.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* MybatisPlusConfig.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/3 at 4:46 PM
* Suffering is the most powerful teacher of life.
*/
@Configuration
@MapperScan("com.baomidou.cloud.service.*.mapper*")
public class MybatisPlusConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
//
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2));
return interceptor;
}
}
package com.matrix.md.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* SpringFoxConfig.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/22 at 5:28 下午
*/
@Configuration
@EnableSwagger2
public class SpringFoxConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
package com.matrix.md.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
/**
* WebMvcConfigConfig.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/22 at 5:30 下午
*/
@Configuration
public class WebMvcConfigConfig extends WebMvcConfigurationSupport {
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**").addResourceLocations(
"classpath:/static/");
registry.
addResourceHandler("/swagger-ui/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/")
.resourceChain(false);
super.addResourceHandlers(registry);
}
}
package com.matrix.md.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* WebSocketConfig.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 7:17 PM
* Suffering is the most powerful teacher of life.
*/
@Configuration
public class WebSocketConfig {
/**
* 服务器节点
* 如果使用独立的servlet容器,而不是直接使用springboot的内置容器,就不要注入ServerEndpointExporter,因为它将由容器自己提供和管理
*
* @return ServerEndpointExporter
*/
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
}
package com.matrix.md.consumer;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.matrix.md.entity.MessageLog;
import com.matrix.md.entity.Specification;
import com.matrix.md.entity.trans.MailInfo;
import com.matrix.md.entity.trans.StandardData;
import com.matrix.md.service.ComponentService;
import com.matrix.md.service.MessageLogService;
import com.matrix.md.service.SpecService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Component;
/**
* MailConsumer. 邮件标准的消费服务
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/30 at 5:10 下午
* Suffering is the most powerful teacher of life.
*/
@Slf4j
@Component
public class MailConsumer {
private final String baseEndpoints = "mail";
@Autowired
private JmsMessagingTemplate jmsTemplate;
@Autowired
private SpecService specService;
@Autowired
private ComponentService comService;
@Autowired
private MessageLogService logService;
/**
* 转发到邮件服务
*
* @param text 消息体
*/
@JmsListener(destination = baseEndpoints)
public void receiveQueue(String text) {
StandardData data = JSON.parseObject(text, StandardData.class);
//1.获得当前正在服务的组件 - 获得实际的端点
while (true){
LambdaQueryWrapper<Specification> wrapper = new LambdaQueryWrapper<>();
Long currentComId = specService.getOne(wrapper
.eq(Specification::getEndPoints, baseEndpoints))
.getCurrentComId();
if (currentComId == 0){
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
currentComId = specService.getOne(wrapper
.eq(Specification::getEndPoints, baseEndpoints))
.getCurrentComId();
}else {
com.matrix.md.entity.Component component = comService.getById(currentComId);
String endPoints = String.format("%s.%s.%s",
component.getComNumber(), baseEndpoints, data.getApi());
MailInfo mailInfo = data.getData();
//2.log
String handleCom = "";
if ("x001x001.mail.send".equals(endPoints)) {
handleCom = "qq邮箱组件";
}
if ("x001x002.mail.send".equals(endPoints)) {
handleCom = "新浪邮箱组件";
}
MessageLog sendLog = new MessageLog("文本数据", "测试组件1", handleCom, (long) data.getData().getContent().getBytes().length,
false, "成功");
logService.save(sendLog);
log.info("总线接受到mail标准下 {}组件请求,要访问的api是 {},实际路由的端点是{},发送给",
data.getFrom(), data.getApi(), endPoints);
jmsTemplate.convertAndSend(endPoints, JSON.toJSON(mailInfo).toString());
break;
}
}
}
}
package com.matrix.md.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.matrix.md.entity.BaseEntity;
import com.matrix.md.entity.Specification;
import com.matrix.md.entity.vo.ComponentVo;
import com.matrix.md.service.ComponentService;
import com.matrix.md.service.SpecService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import static java.util.stream.Collectors.toMap;
/**
* ComponentController.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/1 at 1:08 下午
* Suffering is the most powerful teacher of life.
*/
@RestController
@RequestMapping("/components")
@Api(tags = "组件接口")
public class ComponentController {
@Autowired
private ComponentService componentService;
@Autowired
private SpecService specService;
@GetMapping
@ApiOperation(value = "分页获取组件页信息")
public ResponseEntity<IPage<ComponentVo>> findAll(@RequestParam int page) {
List<Specification> specList = specService.list();
Map<Long, String> nameMap = specList.stream()
.collect(toMap(BaseEntity::getId, Specification::getName));
Map<Long, String> bindMap = specList.stream()
.filter(s -> s.getCurrentComId() > 0)
.collect(toMap(Specification::getCurrentComId, Specification::getName));
// paging queries component and convert Page<Component> to Page<componentVo> by chain
IPage<ComponentVo> pageVo = componentService.page(Page.of(page, 10))
.convert(c -> ComponentVo.transVo(c, nameMap, bindMap));
return ResponseEntity.ok(pageVo);
}
}
package com.matrix.md.controller;
import com.matrix.md.config.ActiveMQUtil;
import com.matrix.md.entity.vo.MessageMetrics;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* MessageController.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/24 at 5:07 下午
*/
@RestController
@RequestMapping("/messages")
@Api(tags = "总线通信管理接口")
public class MessageController {
@Autowired
private ActiveMQUtil mqUtil;
@GetMapping
@ApiModelProperty(value = "获取消息总线消息")
public ResponseEntity<Map<String, MessageMetrics>> messages() {
Map<String, MessageMetrics> queueInfos = mqUtil.getQueueInfos();
return ResponseEntity.ok(queueInfos);
}
}
package com.matrix.md.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.matrix.md.entity.MessageLog;
import com.matrix.md.service.MessageLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
/**
* MessageLogController.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 4:04 AM
* Suffering is the most powerful teacher of life.
*/
@RequestMapping("/messageLogs")
@RestController
@Api(tags = "消息日志接口")
public class MessageLogController {
private final MessageLogService messageLogService;
public MessageLogController(MessageLogService messageLogService) {
this.messageLogService = messageLogService;
}
/**
* paging query message logs.
*/
@GetMapping
@ApiOperation("分页查询消息日志")
public ResponseEntity<Page<MessageLog>> query(int page) {
Page<MessageLog> messageLogs = messageLogService.page(new Page<>(page, 10));
return ResponseEntity.ok(messageLogs);
}
}
package com.matrix.md.controller;
import com.matrix.md.bean.ShardingData;
import com.matrix.md.entity.vo.ServerInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* ServerController.
* 服务器的路由器,用于处理组件注册.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 12:35 上午
* Suffering is the most powerful teacher of life.
*/
@RestController
@RequestMapping("/server")
@Api(tags = "服务发现注册Demo")
public class ServerController {
@Autowired
private ShardingData shardingData;
@ApiOperation("服务地址的注册与更新")
@PostMapping("/register")
public ResponseEntity<String> register(@RequestBody ServerInfo serverInfo){
shardingData.registerAddress(serverInfo);
return ResponseEntity.ok("register success");
}
@ApiOperation("展示服务列表")
@GetMapping("/list")
public ResponseEntity<Map<String,String>> showServerList(){
return ResponseEntity.ok(shardingData.getComponentAddress());
}
}
package com.matrix.md.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.matrix.md.entity.Component;
import com.matrix.md.entity.Specification;
import com.matrix.md.entity.vo.InterVo;
import com.matrix.md.entity.vo.SpecificationVo;
import com.matrix.md.service.ComponentService;
import com.matrix.md.service.InterService;
import com.matrix.md.service.SpecService;
import com.matrix.md.websocket.SocketData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* SpecController.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/1 at 11:57 上午
* Suffering is the most powerful teacher of life.
*/
@RestController
@RequestMapping("/specs")
@Api(tags = "规范接口")
public class SpecController {
@Autowired
private SpecService specService;
@Autowired
private ComponentService comService;
@Autowired
private InterService interService;
/**
* 根据specId查询规范
*/
@GetMapping("/{specId}")
@ApiOperation("根据specId查询规范")
public ResponseEntity<Specification> getSpecById(@ApiParam("规范id") @PathVariable("specId") String specId) {
Specification spec = specService.getById(specId);
Component component = comService.getById(spec.getCurrentComId());
return ResponseEntity.ok(spec.toVo(component == null ? "无绑定组件" : component.getName()));
}
/**
* 根据规范id获得规范
*
* @param page 页码
* @return 规范列表
*/
@GetMapping
@ApiOperation(value = "分页获取所有规范")
public ResponseEntity<IPage<SpecificationVo>> findAll(@RequestParam int page) {
IPage<SpecificationVo> result = specService.page(Page.of(page, 10), Wrappers.emptyWrapper())
.convert(s -> {
Component component = comService.getById(s.getCurrentComId());
return s.toVo(component == null ? "无绑定组件" : component.getName());
});
return ResponseEntity.ok(result);
}
/**
* 根据规范id获得规范关联的组件
*
* @param specId 规范id
* @return 组件列表
*/
@GetMapping("/components")
@ApiOperation(value = "根据规范id获得规范关联的组件")
public ResponseEntity<List<Component>> findComponents(@RequestParam int specId) {
String idString = String.valueOf(specId);
List<Component> componentList = comService.list(Wrappers.lambdaQuery(Component.class)
.eq(Component::getSpecAbleIds, idString));
return ResponseEntity.ok(componentList);
}
/**
* 更改规范绑定的组件id
*
* @param specId 规范id
* @param componentId 要新绑定的组件id
* @return 是否成功
*/
@PutMapping
@ApiOperation(value = "更改规范绑定的组件id")
public ResponseEntity<String> updateComponents(
@RequestParam @ApiParam(name = "specId", value = "规范id") long specId,
@RequestParam @ApiParam(name = "componentId", value = "要新绑定的组件id") long componentId) {
boolean result = specService.lambdaUpdate()
.eq(Specification::getId, specId)
.set(Specification::getCurrentComId, componentId)
.update();
SocketData.updateActiveComponent(componentId);
return ResponseEntity.ok(result ? "更新成功" : "更新失败");
}
/**
* 解除规范绑定的组件
*
* @param specId 规范id
* @return 是否成功
*/
@DeleteMapping("/components")
@ApiOperation(value = "解除规范绑定的组件")
public ResponseEntity<String> deleteComponents(@RequestParam @ApiParam(name = "specId", value = "规范id") long specId) {
boolean result = specService.lambdaUpdate()
.eq(Specification::getId, specId)
.set(Specification::getCurrentComId, 0)
.update();
SocketData.updateActiveComponent(0);
return ResponseEntity.ok(result ? "更新成功" : "更新失败");
}
/**
* 根据规范id获得关联的接口Vo
*
* @param specId 规范id
* @return 接口Vo列表
*/
@GetMapping("/interfaces")
@ApiOperation(value = "根据规范id获得关联的接口Vo")
public ResponseEntity<List<InterVo>> getInterVos(@RequestParam long specId) {
List<InterVo> interVos = interService.getInterfaceBySpecId(specId);
return ResponseEntity.ok(interVos);
}
}
package com.matrix.md.controller;
import com.matrix.md.websocket.WebSocket;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* WebsocketController.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 7:56 PM
* Suffering is the most powerful teacher of life.
*/
@RestController
@RequestMapping("/websocket")
public class WebsocketController {
@GetMapping("/start")
public ResponseEntity<String> startSend() {
WebSocket.sendMessage("Hello");
return ResponseEntity.ok("ok");
}
}
package com.matrix.md.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/**
* BaseEntity.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/22 at 4:02 下午
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "基础对象")
public abstract class BaseEntity {
/**
* 主键id
*/
@TableId(type = IdType.AUTO)
@ApiModelProperty("主键id,从0开始自增")
private Long id;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@ApiModelProperty("数据创建时间")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
private LocalDateTime createTime;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@ApiModelProperty("数据更新时间")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
private LocalDateTime updateTime;
}
package com.matrix.md.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.beans.Transient;
import java.time.LocalDateTime;
/**
* Component.
* 组件对象
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/22 at 4:02 下午
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("组件对象")
public class Component extends BaseEntity{
@ApiModelProperty(value = "组件编号")
private String comNumber;
@ApiModelProperty(value = "组件名称")
private String name;
@ApiModelProperty(value = "组件ip")
private String ip;
@ApiModelProperty(value = "该组件适用的规范列表Id,以英文状态下的逗号','作为分隔符")
private String specAbleIds;
}
package com.matrix.md.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
import java.util.List;
/**
* InterInfo.
* interface-information 接口信息 - Demo中与{@link Specification} 强绑定
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/22 at 5:17 下午
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("接口信息")
public class InterInfo extends BaseEntity {
@ApiModelProperty("接口名称")
private String name;
@ApiModelProperty("接口描述")
private String des;
@ApiModelProperty("接口地址")
private String address;
@ApiModelProperty("请求方式 HTTP-GET/HTTP-POST/SOCKET")
private String requestMethod;
@ApiModelProperty("参数类型 - JSON")
private String paramType;
@ApiModelProperty("关联的规范主键id")
private Long specId;
}
package com.matrix.md.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
/**
* InterParam.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/22 at 5:19 下午
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("接口参数")
public class InterParam extends BaseEntity {
@ApiModelProperty("参数名称")
private String fieldName;
@ApiModelProperty("参数描述")
private String fieldDes;
@ApiModelProperty("参数类型")
private String fieldType;
@ApiModelProperty("是否必填 1true-必须填 0false-非必填")
private boolean required;
@ApiModelProperty("关联的接口信息id")
private Long infoId;
}
package com.matrix.md.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
/**
* InterResponse.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/22 at 5:20 下午
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("接口返回值")
public class InterResponse extends BaseEntity{
@ApiModelProperty("返回值参数名称")
private String fieldName;
@ApiModelProperty("返回值参数描述")
private String fieldDes;
@ApiModelProperty("返回值参数类型")
private String fieldType;
@ApiModelProperty("返回值关联的接口信息id")
private Long infoId;
}
package com.matrix.md.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* MessageLog.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 3:57 AM
* Suffering is the most powerful teacher of life.
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("消息日志")
public class MessageLog extends BaseEntity {
@ApiModelProperty("数据类型")
private String dataType;
@ApiModelProperty("发送组件")
private String sendCom;
@ApiModelProperty("接收组件")
private String handleCom;
@ApiModelProperty("数据大小")
private Long dataSize;
@ApiModelProperty("是否限流")
private boolean isLimit;
@ApiModelProperty("通信结果")
private String result;
}
package com.matrix.md.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* PageData.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/1 at 10:24 PM
* Suffering is the most powerful teacher of life.
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(description = "分页数据")
public class PageData<T> {
@ApiModelProperty(value = "当前页码")
private int page;
@ApiModelProperty(value = "每页条数")
private int size;
@ApiModelProperty(value = "总条数")
private int total;
@ApiModelProperty(value = "数据")
private T data;
}
package com.matrix.md.entity;
import com.matrix.md.bean.BeanHelper;
import com.matrix.md.entity.vo.SpecificationVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.modelmapper.ModelMapper;
/**
* Specification.
* 规范标准
* 和组件的关系是组件可以实现多个规范,规范当前只能选择某一个组件作为当前规范的实现,一个组件可以同时服务多个规范
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/22 at 4:00 下午
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "规范标准")
public class Specification extends BaseEntity {
@ApiModelProperty(value = "规范的名称")
private String name;
@ApiModelProperty(value = "规范编号")
private String specNumber;
@ApiModelProperty(value = "规范的描述")
private String des;
@ApiModelProperty(value = "绑定的MQ的端点")
private String endPoints;
@ApiModelProperty(value = "规范的适用范围")
private String applyRange;
@ApiModelProperty(value = "规范当前绑定的组件id,如果没有绑定则为0,默认为0")
private Long currentComId = 0L;
public SpecificationVo toVo(String currentComName) {
ModelMapper mapper = BeanHelper.getUserMapper();
SpecificationVo vo = mapper.map(this, SpecificationVo.class);
vo.setComName(currentComName);
return vo;
}
}
package com.matrix.md.entity.trans;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* MailInfo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 1:44 上午
* Suffering is the most powerful teacher of life.
*/
@Data
@ApiModel("邮件信息体")
public class MailInfo {
@ApiModelProperty(value = "邮件标题",example = "QQ邮件的标题")
private String title;
@ApiModelProperty(value = "发送的邮件终点地址",example = "xhyrzldf@gmail.com")
private String mailAddress;
@ApiModelProperty(value = "发送的邮件内容",example = "This is a test mail")
private String content;
}
package com.matrix.md.entity.trans;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* StandardData.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/30 at 5:17 下午
* Suffering is the most powerful teacher of life.
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("向总线通信的标准数据")
public class StandardData {
@ApiModelProperty("该消息来自于哪个组件-组件名(demo)")
private String from;
@ApiModelProperty("该消息要发送的接口地址")
private String api;
@ApiModelProperty("该消息的数据内容")
private MailInfo data;
}
package com.matrix.md.entity.vo;
import com.matrix.md.bean.BeanHelper;
import com.matrix.md.entity.Component;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.modelmapper.ModelMapper;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* ComponentVo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/1 at 1:11 下午
* Suffering is the most powerful teacher of life.
*/
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel("组件的显示层")
public class ComponentVo extends Component {
@ApiModelProperty(value = "绑定的名称,没有绑定显示无")
private String bindingName;
@ApiModelProperty(value = "适用的规范名称列表")
private List<String> adaptList;
public static ComponentVo transVo(Component component, Map<Long, String> specNameMap, Map<Long, String> bindMap) {
ModelMapper mapper = BeanHelper.getUserMapper();
ComponentVo vo = mapper.map(component, ComponentVo.class);
String bindingName = bindMap.getOrDefault(vo.getId(), "无");
List<String> adaptList = Arrays.stream(vo.getSpecAbleIds().split(","))
.map(Long::valueOf)
.map(key -> specNameMap.getOrDefault(key,"暂无适配规范"))
.collect(Collectors.toList());
vo.setBindingName(bindingName);
vo.setAdaptList(adaptList);
return vo;
}
}
package com.matrix.md.entity.vo;
import com.matrix.md.entity.InterInfo;
import com.matrix.md.entity.InterParam;
import com.matrix.md.entity.InterResponse;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* InterVo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 4:41 PM
* Suffering is the most powerful teacher of life.
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("接口信息的vo类")
public class InterVo {
@ApiModelProperty("接口信息")
private InterInfo interInfo;
@ApiModelProperty("接口参数列表")
private List<InterParam> interParams;
@ApiModelProperty("接口返回值参数列表")
private List<InterResponse> interResponses;
}
package com.matrix.md.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* MessageMetrics.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 2:52 AM
* Suffering is the most powerful teacher of life.
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("消息统计指标")
public class MessageMetrics {
@ApiModelProperty("通信规范名称")
private String name;
@ApiModelProperty("关联组件名称")
private String processName;
@ApiModelProperty("消息数据类型")
private String type;
@ApiModelProperty("端点名称")
private String endpoint;
@ApiModelProperty("正在处理的消息数")
private Long pending;
@ApiModelProperty("应用组件数量")
private Long consumers;
@ApiModelProperty("已发送消息数")
private Long enqueued;
@ApiModelProperty("已处理消息数")
private Long dequeued;
@ApiModelProperty("最大滞留时间")
private Long maxEnqueuedTime;
@ApiModelProperty("最小滞留时间")
private Long minEnqueuedTime;
@ApiModelProperty("平均滞留时间")
private Double avgEnqueuedTime;
@ApiModelProperty("最大消息大小")
private Long maxMessageSize;
@ApiModelProperty("最小消息大小")
private Long minMessageSize;
@ApiModelProperty("平均消息大小")
private Long avgMessageSize;
}
package com.matrix.md.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* ServerInfo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/25 at 12:43 上午
* Suffering is the most powerful teacher of life.
*/
@Data
@ApiModel("服务器信息,模拟服务注册")
public class ServerInfo {
@ApiModelProperty("组件编号")
private String comNumber;
@ApiModelProperty("组件地址")
private String comAddress;
}
package com.matrix.md.entity.vo;
import com.matrix.md.bean.BeanHelper;
import com.matrix.md.entity.Specification;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.modelmapper.ModelMapper;
/**
* SpecificationVo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 2:53 PM
* Suffering is the most powerful teacher of life.
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("SpecVo显示层对象")
public class SpecificationVo extends Specification {
@ApiModelProperty("组件名称")
private String comName;
}
package com.matrix.md.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.matrix.md.entity.Component;
import org.springframework.stereotype.Repository;
/**
* ComponentMapper.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/30 at 6:51 下午
* Suffering is the most powerful teacher of life.
*/
@Repository
public interface ComponentMapper extends BaseMapper<Component> {
}
package com.matrix.md.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.matrix.md.entity.InterInfo;
import org.springframework.stereotype.Repository;
/**
* InterMapper.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 4:37 PM
* Suffering is the most powerful teacher of life.
*/
@Repository
public interface InterInfoMapper extends BaseMapper<InterInfo> {
}
package com.matrix.md.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.matrix.md.entity.InterParam;
import org.springframework.stereotype.Repository;
/**
* InterParamMapper.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 4:45 PM
* Suffering is the most powerful teacher of life.
*/
@Repository
public interface InterParamMapper extends BaseMapper<InterParam> {
}
package com.matrix.md.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.matrix.md.entity.InterResponse;
import org.springframework.stereotype.Repository;
/**
* InterResponseMapper.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 4:45 PM
* Suffering is the most powerful teacher of life.
*/
@Repository
public interface InterResponseMapper extends BaseMapper<InterResponse> {
}
package com.matrix.md.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.matrix.md.entity.MessageLog;
import org.springframework.stereotype.Repository;
/**
* MessageLogMapper.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 4:01 AM
* Suffering is the most powerful teacher of life.
*/
@Repository
public interface MessageLogMapper extends BaseMapper<MessageLog> {
}
package com.matrix.md.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.matrix.md.entity.Specification;
import org.springframework.stereotype.Repository;
/**
* SpecMapper.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/23 at 7:00 下午
*/
@Repository
public interface SpecMapper extends BaseMapper<Specification> {
}
package com.matrix.md.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.matrix.md.entity.Component;
import org.springframework.stereotype.Service;
/**
* ComponentService.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/30 at 5:48 下午
* Suffering is the most powerful teacher of life.
*/
public interface ComponentService extends IService<Component> {
}
package com.matrix.md.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.matrix.md.entity.InterInfo;
import com.matrix.md.entity.vo.InterVo;
import java.util.List;
/**
* InterService.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 4:38 PM
* Suffering is the most powerful teacher of life.
*/
public interface InterService extends IService<InterInfo> {
List<InterVo> getInterfaceBySpecId(Long specId);
}
package com.matrix.md.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.matrix.md.entity.MessageLog;
/**
* MessageLogService.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 4:01 AM
* Suffering is the most powerful teacher of life.
*/
public interface MessageLogService extends IService<MessageLog> {
}
package com.matrix.md.service;
import com.matrix.md.entity.Specification;
import java.util.List;
/**
* MessageService.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/22 at 7:13 下午
*/
public interface MessageService {
/**
* 查询所有可用规范的当前状态
*/
List<Specification> findAllSpecs();
/**
* 更改绑定
*
* @param specId 规范id
* @param componentId 新绑定的组件主键id
* @return 是否绑定成功
*/
boolean updateBindComponent(Long specId, Long componentId);
Specification findByEndpoints(String endPoints);
}
package com.matrix.md.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.matrix.md.entity.Specification;
/**
* SpecService.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/30 at 6:55 下午
* Suffering is the most powerful teacher of life.
*/
public interface SpecService extends IService<Specification> {
}
package com.matrix.md.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.matrix.md.entity.Component;
import com.matrix.md.mapper.ComponentMapper;
import com.matrix.md.service.ComponentService;
import org.springframework.stereotype.Service;
/**
* ComponentServiceImpl.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/30 at 6:45 下午
* Suffering is the most powerful teacher of life.
*/
@Service
public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component>
implements ComponentService {
}
package com.matrix.md.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.matrix.md.entity.InterInfo;
import com.matrix.md.entity.InterParam;
import com.matrix.md.entity.InterResponse;
import com.matrix.md.entity.vo.InterVo;
import com.matrix.md.mapper.InterInfoMapper;
import com.matrix.md.mapper.InterParamMapper;
import com.matrix.md.mapper.InterResponseMapper;
import com.matrix.md.service.InterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
* InterServiceImpl.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 4:39 PM
* Suffering is the most powerful teacher of life.
*/
@Service
public class InterServiceImpl extends ServiceImpl<InterInfoMapper, InterInfo> implements InterService {
@Autowired
private InterInfoMapper infoMapper;
@Autowired
private InterParamMapper paramMapper;
@Autowired
private InterResponseMapper responseMapper;
@Override
public List<InterVo> getInterfaceBySpecId(Long specId) {
LambdaQueryWrapper<InterInfo> infoWrapper = new LambdaQueryWrapper<>();
return infoMapper.selectList(infoWrapper.eq(InterInfo::getSpecId, specId)).stream()
.map(this::assemblingInterface)
.collect(Collectors.toList());
}
/**
* 组装接口信息
*
* @param info 基础接口
* @return 组装后的接口信息
*/
private InterVo assemblingInterface(InterInfo info) {
InterVo vo = new InterVo();
vo.setInterInfo(info);
LambdaQueryWrapper<InterParam> paramWrapper = new LambdaQueryWrapper<>();
LambdaQueryWrapper<InterResponse> responseWrapper = new LambdaQueryWrapper<>();
List<InterParam> params = paramMapper.selectList(paramWrapper.eq(InterParam::getInfoId, info.getId()));
List<InterResponse> response = responseMapper.selectList(responseWrapper.eq(InterResponse::getInfoId, info.getId()));
vo.setInterParams(params);
vo.setInterResponses(response);
return vo;
}
}
package com.matrix.md.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.matrix.md.entity.MessageLog;
import com.matrix.md.mapper.MessageLogMapper;
import com.matrix.md.service.MessageLogService;
import org.springframework.stereotype.Service;
/**
* MessageLogServiceImpl.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 4:02 AM
* Suffering is the most powerful teacher of life.
*/
@Service
public class MessageLogServiceImpl extends ServiceImpl<MessageLogMapper, MessageLog> implements MessageLogService {
}
package com.matrix.md.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.matrix.md.entity.Specification;
import com.matrix.md.mapper.SpecMapper;
import com.matrix.md.service.SpecService;
import org.springframework.stereotype.Service;
/**
* SpecServiceImpl.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/11/30 at 6:57 下午
* Suffering is the most powerful teacher of life.
*/
@Service
public class SpecServiceImpl extends ServiceImpl<SpecMapper, Specification>
implements SpecService {
}
package com.matrix.md.websocket;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* ComponentFlow. 组件流量
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/3 at 11:15 AM
* Suffering is the most powerful teacher of life.
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("组件流量")
public class ComponentFlow {
@ApiModelProperty("组件名称")
private String name;
@ApiModelProperty("上行流-kb")
private double upStream;
@ApiModelProperty("下行流-kb")
private double downStream;
@ApiModelProperty("关联类型 1-关联正常,2-需要被处理,3-无流量")
private int type;
}
package com.matrix.md.websocket;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
* socketData.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 7:30 PM
* Suffering is the most powerful teacher of life.
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("监控页面的webSocket数据")
@JsonPropertyOrder({"timeStamp", "transFlow", "componentFlows"})
public class SocketData {
@JsonIgnore
private static long activeComponent = 1;
@ApiModelProperty("时间戳 yyyy-MM-dd hh:mm:ss")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
private LocalDateTime timeStamp;
@ApiModelProperty("传输流量")
private TransFlow transFlow;
@ApiModelProperty("组件流量列表")
private List<ComponentFlow> componentFlows;
/**
* 生产一组组件的流量
*
* @return 组件流量
*/
public static SocketData produce() {
TransFlow transFlow = TransFlow.produce();
List<ComponentFlow> flows = new ArrayList<>();
Random random = new Random();
double variance = 0.5;
ComponentFlow consumer = new ComponentFlow("消费组件A", Math.sqrt(variance) * random.nextGaussian() + Math.random() * 100, Math.sqrt(variance) * random.nextGaussian() + Math.random() * 100, 1);
flows.add(consumer);
ComponentFlow qqMail = new ComponentFlow();
ComponentFlow sinaMail = new ComponentFlow();
if (activeComponent == 0) {
qqMail = new ComponentFlow("QQ邮箱组件", 0, 0, 3);
sinaMail = new ComponentFlow("新浪邮箱组件", 0, 0, 3);
}
if (activeComponent == 1) {
qqMail = new ComponentFlow("QQ邮箱组件", Math.sqrt(variance) * random.nextGaussian() + Math.random() * 100, Math.sqrt(variance) * random.nextGaussian() + Math.random() * 100, 1);
sinaMail = new ComponentFlow("新浪邮箱组件", 0, 0, 3);
}
if (activeComponent == 2) {
qqMail = new ComponentFlow("QQ邮箱组件", 0, 0, 3);
sinaMail = new ComponentFlow("新浪邮箱组件", Math.sqrt(variance) * random.nextGaussian() + Math.random() * 100, Math.sqrt(variance) * random.nextGaussian() + Math.random() * 100, 1);
}
flows.add(qqMail);
flows.add(sinaMail);
return new SocketData(LocalDateTime.now(), transFlow, flows);
}
/**
* update activeComponent
*/
public static void updateActiveComponent(long updatedActiveComponent) {
activeComponent = updatedActiveComponent;
}
/**
* a method that return Incremental random number
*/
public static long getIncrementalRandomNumber() {
return Math.round(Math.random() * 100);
}
}
package com.matrix.md.websocket;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* socketTask.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 7:30 PM
* Suffering is the most powerful teacher of life.
*/
@Component
@Slf4j
public class SocketTask {
private int count;
@Autowired
private ObjectMapper objectMapper;
/**
* 每2秒发送一次socketData
*/
@Scheduled(initialDelay = 5000, fixedRate = 1000)
public void sendSocketData() throws JsonProcessingException {
//使用 jackson 将对象转换为json字符串
if (WebSocket.webSocketSets.size() > 0) {
String testData = objectMapper.writeValueAsString(SocketData.produce());
WebSocket.sendMessage(testData);
}
}
}
package com.matrix.md.websocket;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Random;
/**
* TransFlow.传输流量
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/3 at 11:12 AM
* Suffering is the most powerful teacher of life.
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("传输流量,单位kb")
public class TransFlow {
@JsonIgnore
private static int seed = 2;
@JsonIgnore
private static double maxFlow = 2;
@ApiModelProperty("当前流量")
private double current;
@ApiModelProperty("总流量")
private double total;
@ApiModelProperty("平均流量")
private double average;
@ApiModelProperty("最大流量")
private double max;
/**
* 生产TransFlow数据,方差为1
*/
public static TransFlow produce() {
Random random = new Random();
maxFlow = Math.max(Math.sqrt(1) * random.nextGaussian() + (Math.random() + 2) * 100, maxFlow);
double avg = 120 + 10 * (Math.random() * 2 - 1);
return new TransFlow(
Math.sqrt(1) * random.nextGaussian() + Math.random() * 100,
(Math.random() + seed++) * 200,
avg,
maxFlow);
}
}
package com.matrix.md.websocket;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.websocket.*;
import javax.websocket.server.ServerEndpoint;
import java.util.concurrent.CopyOnWriteArraySet;
/**
* WebSocket component
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/12/2 at 8:07 PM
* Suffering is the most powerful teacher of life.
*/
@ServerEndpoint(value = "/message")
@Component
@Slf4j
public class WebSocket {
/**
* 用来存储每个会话的session,静态的不会被实例化
*/
public static CopyOnWriteArraySet<WebSocket> webSocketSets = new CopyOnWriteArraySet<>();
/**
* 每个浏览器连接都会有一个新的会话对象
*/
private Session session;
/**
* 所有客户端发送消息
*
* @param message 消息
*/
public static void sendMessage(String message) {
for (WebSocket ws : webSocketSets) {
ws.session.getAsyncRemote().sendText(message);
}
}
/**
* 主要用来监听连接建立,config用来获取WebsocketConfig中的配置信息
*
* @param session 会话
* @param config 配置信息
*/
@OnOpen
public void onOpen(Session session, EndpointConfig config) {
this.session = session;
webSocketSets.add(this);
log.info("[websocket消息] 有新的连接, 总数:{}", webSocketSets.size());
}
@OnClose
public void onClose() {
webSocketSets.remove(this);
log.info("[websocket消息]连接断开, 总数:{}", webSocketSets.size());
}
@OnError
public void onError(Throwable e, Session session) {
webSocketSets.remove(this);
log.info("[websocket消息]连接出错或未关闭socket:" + e.getMessage());
}
@OnMessage
public void onMessage(String message, Session session) {
for (WebSocket ws : webSocketSets) {
ws.session.getAsyncRemote().sendText("广播:" + message);
}
log.info("[websocket消息]收到客户端发来的消息:{}", message);
}
}
spring:
# DataSource
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
schema: classpath:db/scheme.sql
data: classpath:db/data.sql
url: jdbc:mysql://127.0.0.1:3306/message_demo?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
username: root
password: ldf3291369
initialization-mode: always
\ No newline at end of file
spring:
# DataSource
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
schema: classpath:db/scheme.sql
data: classpath:db/data.sql
url: jdbc:mysql://123.60.63.178:3306/message_demo?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
username: root
password: qwer1234
initialization-mode: always
\ No newline at end of file
active:
connectorPort: 11099
connectorPath: /jmxrmi
jmxDomain: org.apache.activemq
connectorIp: 127.0.0.1
brokerName: localhost
spring:
application:
name: message-demo
profiles:
active: dev
jackson:
serialization:
WRITE_DATES_AS_TIMESTAMPS: false
# ActiveMQ
activemq:
broker-url: tcp://127.0.0.1:61616
user: admin
password: admin
pool:
enabled: true
max-connections: 100
# Log
logging:
level:
com:
matrix:
md:
mapper=: debug
file:
name: log/message-demo.log
config: classpath:logback-spring.xml
server:
port: 8180
\ No newline at end of file
# 规范数据
delete
from specification;
INSERT INTO `specification`(`id`, `create_time`, `update_time`, `name`, `spec_number`, `des`, `end_points`,
`apply_range`, `current_com_id`)
VALUES (1, '2021-11-23 20:19:07', '2021-11-23 20:19:07', '邮件规范', 'x001', '用来处理邮件相关事项的规范', 'mail', '1', 1);
# 组件数据
delete
from component;
insert into component(id, create_time, update_time, com_number,ip, name, spec_able_ids)
values (1, '2021-11-23 20:19:07', '2021-11-23 20:19:07','x001x001','127.0.0.1', 'qq邮箱组件', 1);
insert into component(id, create_time, update_time, com_number, ip,name, spec_able_ids)
values (2, '2021-11-23 20:19:07', '2021-11-23 20:19:07', 'x001x002', '127.0.0.1','新浪邮箱组件', 1);
insert into component(id, create_time, update_time, com_number, ip,name, spec_able_ids)
values (3, '2021-11-23 20:19:07', '2021-11-23 20:19:07', 'x000x001','127.0.0.1', '测试组件1', 0);
# 接口数据
delete
from inter_info;
insert into inter_info(id, create_time, update_time, name, des, address, request_method, param_type, spec_id)
VALUES (1, '2021-11-23 20:19:07', '2021-11-23 20:19:07', '发送邮件接口', '给定指定消息数据,以邮件的形式发送出去', '/send', 'socket', 'socket',
1);
# 接口参数
delete
from inter_param;
insert into inter_param(id, create_time, update_time, field_name, field_des, field_type, required, info_id)
VALUES (1, '2021-11-23 20:19:07', '2021-11-23 20:19:07', 'title', '邮件标题', 'varchar', 1, 1),
(2, '2021-11-23 20:19:07', '2021-11-23 20:19:07', 'content', '邮件内容', 'varchar', 1, 1),
(3, '2021-11-23 20:19:07', '2021-11-23 20:19:07', 'mailAddress', '邮件接收方地址', 'varchar', 1, 1);
# 接口返回值
delete
from inter_response;
insert into inter_response (id, create_time, update_time, field_name, field_des, field_type, info_id)
values (1, '2021-11-23 20:19:07', '2021-11-23 20:19:07', 'code', '返回码', 'varchar', 1),
(2, '2021-11-23 20:19:07', '2021-11-23 20:19:07', 'msg', '返回信息', 'varchar', 1);
\ No newline at end of file
# reset tables
use message_demo;
DROP TABLE IF EXISTS specification;
CREATE TABLE specification
(
id BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
create_time datetime NULL DEFAULT NULL COMMENT '创建时间',
update_time datetime NULL DEFAULT NULL COMMENT '更新时间',
name VARCHAR(50) NULL DEFAULT NULL COMMENT '规范的名称',
spec_number VARCHAR(50) NULL DEFAULT NULL COMMENT '规范编号',
des VARCHAR(50) NULL DEFAULT NULL COMMENT '规范的描述',
end_points VARCHAR(50) NULL DEFAULT NULL COMMENT '绑定的MQ的端点',
apply_range VARCHAR(50) NULL DEFAULT NULL COMMENT '规范的适用范围',
current_com_id bigint(20) not null default 0 COMMENT '规范当前绑定的组件id,如果没有绑定则为0,默认为0',
PRIMARY KEY (id)
) comment '规范标准';
DROP TABLE IF EXISTS component;
CREATE TABLE component
(
id BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
create_time datetime NULL DEFAULT NULL COMMENT '创建时间',
update_time datetime NULL DEFAULT NULL COMMENT '更新时间',
com_number VARCHAR(50) NULL DEFAULT NULL COMMENT 'ip',
ip VARCHAR(50) NULL DEFAULT NULL COMMENT '组件编号',
name VARCHAR(50) NULL DEFAULT NULL COMMENT '组件名称',
spec_able_ids VARCHAR(50) NULL DEFAULT NULL COMMENT '组件适用的规范列表Id',
PRIMARY KEY (id)
) comment '组件';
drop table if exists message_log;
DROP TABLE IF EXISTS inter_info;
CREATE TABLE inter_info
(
id BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
create_time datetime NULL DEFAULT NULL COMMENT '创建时间',
update_time datetime NULL DEFAULT NULL COMMENT '更新时间',
name VARCHAR(50) NULL DEFAULT NULL COMMENT '接口名称',
des VARCHAR(50) NULL DEFAULT NULL COMMENT '接口描述',
address VARCHAR(50) NULL DEFAULT NULL COMMENT '接口地址',
request_method VARCHAR(50) NULL DEFAULT NULL COMMENT '请求方式 HTTP-GET/HTTP-POST/SOCKET',
param_type VARCHAR(50) NULL DEFAULT NULL COMMENT '参数类型 - JSON',
spec_id bigint(20) not null default 0 COMMENT '关联的规范主键id',
PRIMARY KEY (id)
) comment '接口信息';
drop table if exists message_log;
create table message_log
(
id BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
create_time datetime NULL DEFAULT NULL COMMENT '创建时间',
update_time datetime NULL DEFAULT NULL COMMENT '更新时间',
data_type VARCHAR(50) NULL DEFAULT NULL COMMENT '数据类型',
send_com VARCHAR(50) NULL DEFAULT NULL COMMENT '发送组件',
handle_com VARCHAR(50) NULL DEFAULT NULL COMMENT '处理组件',
data_size VARCHAR(50) NULL DEFAULT NULL COMMENT '数据大小',
is_limit boolean NULL DEFAULT NULL COMMENT '是否限流',
result VARCHAR(50) NULL DEFAULT NULL COMMENT '通信结果',
PRIMARY KEY (id)
) comment '消息日志';
DROP TABLE IF EXISTS inter_param;
CREATE TABLE inter_param
(
id BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
create_time datetime NULL DEFAULT NULL COMMENT '创建时间',
update_time datetime NULL DEFAULT NULL COMMENT '更新时间',
field_name VARCHAR(50) NULL DEFAULT NULL COMMENT '参数名称',
field_des VARCHAR(50) NULL DEFAULT NULL COMMENT '参数描述',
field_type VARCHAR(50) NULL DEFAULT NULL COMMENT '参数类型',
required boolean not null default true COMMENT '是否必填 1true-必须填 0false-非必填',
info_id bigint(20) not null default 0 COMMENT '关联的接口信息id',
PRIMARY KEY (id)
) comment '接口参数';
DROP TABLE IF EXISTS inter_response;
CREATE TABLE inter_response
(
id BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
create_time datetime NULL DEFAULT NULL COMMENT '创建时间',
update_time datetime NULL DEFAULT NULL COMMENT '更新时间',
field_name VARCHAR(50) NULL DEFAULT NULL COMMENT '返回值参数名称',
field_des VARCHAR(50) NULL DEFAULT NULL COMMENT '返回值参数描述',
field_type VARCHAR(50) NULL DEFAULT NULL COMMENT '返回值参数类型',
info_id bigint(20) not null default 0 COMMENT '关联的接口信息id',
PRIMARY KEY (id)
) comment '接口返回值';
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径 -->
<property name="LOG_HOME" value="./logs" />
<property name="AppName" value="msg-demo" />
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}-%msg %n</pattern>
</encoder>
</appender>
<!-- 设置分割 -->
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 设置按尺寸和时间(同时满足)分割 -->
<rollingPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>${LOG_HOME}/${AppName}.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<!-- each file should be at most 20MB, keep 360 days worth of history,
but at most 3GB -->
<maxFileSize>20MB</maxFileSize>
<maxHistory>360</maxHistory>
<totalSizeCap>30GB</totalSizeCap>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}-%msg%n</pattern>
</encoder>
</appender>
<!-- 日志输出级别 -->
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
\ No newline at end of file
package com.matrix.md;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class MessageDemoApplicationTests {
@Test
void contextLoads() {
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.matrix</groupId>
<artifactId>message-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>message-demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<packaging>pom</packaging>
<modules>
<module>message-bus</module>
<module>mail-qq</module>
<module>mail-163</module>
<module>consumer-A</module>
</modules>
</project>
#!/bin/bash
echo "**********服务器重启脚本**********";
echo "1.运行时候需要指定服务器的端口号以便杀死上一次的程序";
echo "2.服务器jar包需要和脚本文件在同级目录下";
echo -e " ";
# check the port is given
echo "检查用户是否给定端口号参数....";
if [ ! -n "$1" ]; then
echo "没有指定端口号,脚本退出(请指定服务器的端口号)...";
exit
fi
echo -e " 检查成功!";
# try to kill process
echo will kill the port:$1
for i in `netstat -nltp|awk '{ print $4 " " $7 }'|grep -E ":::$1|0.0.0.0:$1|127.0.0.1:$1}"|awk '{print $2}'`;
do
echo $i;
index=`expr index $i "/"`;
#echo $index;
pid=${i:0:index-1};
echo "即将杀死的进程的进程号id为 [$pid]";
echo "即将杀死的进程的进程名为 [${i:index}]";
if [ ! -n "$pid" ]; then
echo "没有找到指定进程号,将不会执行杀死进程命令";
else
kill -9 $pid
fi
done;
# try to restart server
echo "准备重启服务器....";
nohup java -jar *.jar > /dev/null &
echo "服务器重启成功...按[enter]退出shell..."
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论