2 次代码提交 37df2e1c17 ... b23ed0eff2

作者 SHA1 备注 提交日期
  E_wsq b23ed0eff2 初始化 4 年前
  E_wsq 59e4f9d3d2 初始化 4 年前

+ 26 - 20
.gitignore 查看文件

@@ -1,24 +1,30 @@
1
-# ---> Java
2
-# Compiled class file
3
-*.class
1
+.mvn/
2
+target/
3
+!**/src/main/**
4
+!**/src/test/**
4 5
 
5
-# Log file
6
-*.log
6
+### STS ###
7
+.apt_generated
8
+.classpath
9
+.factorypath
10
+.project
11
+.settings
12
+.springBeans
13
+.sts4-cache
7 14
 
8
-# BlueJ files
9
-*.ctxt
15
+### IntelliJ IDEA ###
16
+.idea
17
+*.iws
18
+*.iml
19
+*.ipr
10 20
 
11
-# Mobile Tools for Java (J2ME)
12
-.mtj.tmp/
13
-
14
-# Package Files #
15
-*.jar
16
-*.war
17
-*.ear
18
-*.zip
19
-*.tar.gz
20
-*.rar
21
-
22
-# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23
-hs_err_pid*
21
+### NetBeans ###
22
+/nbproject/private/
23
+/nbbuild/
24
+/dist/
25
+/nbdist/
26
+/.nb-gradle/
27
+build/
24 28
 
29
+### VS Code ###
30
+.vscode/

+ 17 - 2
README.md 查看文件

@@ -1,3 +1,18 @@
1
-# spring-boot-starter-activemq-demo
1
+这是一个仅使用spring-boot-starter-activemq的演示示例
2
+
3
+使用spring-boot-starter-activemq后变得对于mq消息的生产和消费非常简易,具体请看想应的示例代码。
4
+
5
+与http://gitea.vcarecity.com/ewsq/Spring-boot-starter-activeMQ-JmsMessagingTemplate不同的是,这里面演示了怎么去获取配置文件中的相应信息来配置连接。
6
+
7
+
8
+
9
+knife4j-spring-boot-starter 是用来生成API文档的,启动后访问API的地址是:
10
+
11
+http://127.0.0.1:9090/doc.html
12
+
13
+
14
+
15
+这里也演示了使用SpringBoot自带的quartz去做定时任务。
16
+
17
+
2 18
 
3
-spring-boot-starter-activemq-demo

+ 25 - 0
http/ProducerController.http 查看文件

@@ -0,0 +1,25 @@
1
+### queue
2
+POST http://{{host}}/api/mq/queue/test
3
+Content-Type: application/json
4
+
5
+{
6
+  "tableName": "queue",
7
+  "stamp_start": "2020-11-01 14:58:23",
8
+  "stamp_end": "2020-11-01 15:58:23",
9
+  "offset": 0,
10
+  "limit": 10
11
+}
12
+
13
+### topic
14
+POST http://{{host}}/api/mq/topic/test
15
+Content-Type: application/json
16
+
17
+{
18
+  "tableName": "topic",
19
+  "stamp_start": "2020-11-01 14:58:23",
20
+  "stamp_end": "2020-11-01 15:58:23",
21
+  "offset": 0,
22
+  "limit": 10
23
+}
24
+
25
+

+ 12 - 0
http/http-client.env.json 查看文件

@@ -0,0 +1,12 @@
1
+{
2
+  "dev": {
3
+    "host": "127.0.0.1:9090",
4
+    "limit": "20",
5
+    "offset": "0"
6
+  },
7
+  "production": {
8
+    "host": "127.0.0.1:9090",
9
+    "limit": "20",
10
+    "offset": "0"
11
+  }
12
+}

+ 213 - 0
pom.xml 查看文件

@@ -0,0 +1,213 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0"
3
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
+    <modelVersion>4.0.0</modelVersion>
6
+
7
+    <groupId>com.vcarecity</groupId>
8
+    <artifactId>spring-boot-starter-activemq-demo</artifactId>
9
+    <version>1.0-SNAPSHOT</version>
10
+
11
+
12
+    <distributionManagement>
13
+        <repository>
14
+            <id>nexus-releases</id>
15
+            <name>Nexus Release Repository</name>
16
+            <url>http://maven.vcarecity.com/nexus/content/repositories/releases/</url>
17
+        </repository>
18
+        <snapshotRepository>
19
+            <id>nexus-snapshots</id>
20
+            <name>Nexus Snapshot Repository</name>
21
+            <url>http://maven.vcarecity.com/nexus/content/repositories/snapshots/</url>
22
+        </snapshotRepository>
23
+    </distributionManagement>
24
+
25
+
26
+    <parent>
27
+        <groupId>org.springframework.boot</groupId>
28
+        <artifactId>spring-boot-starter-parent</artifactId>
29
+        <version>2.2.1.RELEASE</version>
30
+        <relativePath/> <!-- lookup parent from repository -->
31
+    </parent>
32
+
33
+    <properties>
34
+        <java.version>1.8</java.version>
35
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36
+        <junit.version>4.13.1</junit.version>
37
+    </properties>
38
+
39
+    <dependencies>
40
+
41
+        <dependency>
42
+            <groupId>junit</groupId>
43
+            <artifactId>junit</artifactId>
44
+            <version>${junit.version}</version>
45
+            <scope>test</scope>
46
+        </dependency>
47
+        <dependency>
48
+            <groupId>org.apache.commons</groupId>
49
+            <artifactId>commons-lang3</artifactId>
50
+            <version>3.11</version>
51
+        </dependency>
52
+        <!-- quartz -->
53
+        <dependency>
54
+            <groupId>org.quartz-scheduler</groupId>
55
+            <artifactId>quartz</artifactId>
56
+        </dependency>
57
+        <!-- Spring Boot Starter -->
58
+        <dependency>
59
+            <groupId>org.springframework.boot</groupId>
60
+            <artifactId>spring-boot-starter</artifactId>
61
+        </dependency>
62
+        <dependency>
63
+            <groupId>org.springframework.boot</groupId>
64
+            <artifactId>spring-boot-starter-web</artifactId>
65
+        </dependency>
66
+
67
+        <!-- Spring Boot Starter Activemq (JMS) -->
68
+        <dependency>
69
+            <groupId>org.springframework.boot</groupId>
70
+            <artifactId>spring-boot-starter-activemq</artifactId>
71
+        </dependency>
72
+
73
+        <!-- Spring Boot Starter Test -->
74
+        <dependency>
75
+            <groupId>org.springframework.boot</groupId>
76
+            <artifactId>spring-boot-starter-test</artifactId>
77
+            <scope>test</scope>
78
+        </dependency>
79
+
80
+        <dependency>
81
+            <groupId>com.github.xiaoymin</groupId>
82
+            <artifactId>knife4j-spring-boot-starter</artifactId>
83
+            <!--在引用时请在maven中央仓库搜索最新版本号 -->
84
+            <version>2.0.3</version>
85
+        </dependency>
86
+
87
+        <!-- xk-time 是时间转换,计算,格式化,解析,日历和cron表达式等的工具,使用Java8,线程安全,简单易用,多达70几种常用日期格式化模板,支持Java8时间类和Date,轻量级,无第三方依赖 -->
88
+        <!-- https://www.oschina.net/news/119438/xk-time-2-2-0-released -->
89
+        <dependency>
90
+            <groupId>com.github.xkzhangsan</groupId>
91
+            <artifactId>xk-time</artifactId>
92
+            <version>2.2.0</version>
93
+        </dependency>
94
+
95
+    </dependencies>
96
+
97
+    <build>
98
+        <finalName>${project.artifactId}</finalName>
99
+        <plugins>
100
+            <!-- java编译插件 -->
101
+            <plugin>
102
+                <groupId>org.apache.maven.plugins</groupId>
103
+                <artifactId>maven-compiler-plugin</artifactId>
104
+                <version>3.2</version>
105
+                <configuration>
106
+                    <source>8</source>
107
+                    <target>8</target>
108
+                    <encoding>UTF-8</encoding>
109
+                </configuration>
110
+            </plugin>
111
+            <!--添加配置跳过测试-->
112
+            <plugin>
113
+                <groupId>org.apache.maven.plugins</groupId>
114
+                <artifactId>maven-surefire-plugin</artifactId>
115
+                <version>2.22.1</version>
116
+                <configuration>
117
+                    <skipTests>true</skipTests>
118
+                </configuration>
119
+            </plugin>
120
+            <!--添加配置跳过测试-->
121
+
122
+            <!--Copy resource -->
123
+            <plugin>
124
+                <artifactId>maven-resources-plugin</artifactId>
125
+                <version>2.7</version>
126
+
127
+                <configuration>
128
+                    <encoding>UTF-8</encoding>
129
+                </configuration>
130
+
131
+                <executions>
132
+                    <execution>
133
+                        <id>copy-resource</id>
134
+                        <phase>package</phase>
135
+                        <goals>
136
+                            <goal>copy-resources</goal>
137
+                        </goals>
138
+                        <configuration>
139
+                            <outputDirectory>${project.build.directory}/config</outputDirectory>
140
+                            <resources>
141
+                                <resource>
142
+                                    <directory>${project.basedir}/src/main/resources</directory>
143
+                                </resource>
144
+                            </resources>
145
+                        </configuration>
146
+                    </execution>
147
+                    <execution>
148
+                        <id>copy-sh</id>
149
+                        <phase>package</phase>
150
+                        <goals>
151
+                            <goal>copy-resources</goal>
152
+                        </goals>
153
+                        <configuration>
154
+                            <outputDirectory>${project.build.directory}</outputDirectory>
155
+                            <resources>
156
+                                <resource>
157
+                                    <directory>${project.basedir}/sh</directory>
158
+                                </resource>
159
+                            </resources>
160
+                        </configuration>
161
+                    </execution>
162
+                    <execution>
163
+                        <id>copy-md</id>
164
+                        <phase>package</phase>
165
+                        <goals>
166
+                            <goal>copy-resources</goal>
167
+                        </goals>
168
+                        <configuration>
169
+                            <outputDirectory>${project.build.directory}</outputDirectory>
170
+                            <resources>
171
+                                <resource>
172
+                                    <directory>${project.basedir}/md</directory>
173
+                                </resource>
174
+                            </resources>
175
+                        </configuration>
176
+                    </execution>
177
+                </executions>
178
+            </plugin>
179
+
180
+            <plugin>
181
+                <groupId>org.apache.maven.plugins</groupId>
182
+                <artifactId>maven-dependency-plugin</artifactId>
183
+                <executions>
184
+                    <execution>
185
+                        <phase>package</phase>
186
+                        <goals>
187
+                            <goal>copy-dependencies</goal>
188
+                        </goals>
189
+                        <configuration>
190
+                            <outputDirectory>${project.build.directory}/libs</outputDirectory>
191
+                        </configuration>
192
+                    </execution>
193
+                </executions>
194
+            </plugin>
195
+
196
+            <plugin>
197
+                <groupId>org.apache.maven.plugins</groupId>
198
+                <artifactId>maven-jar-plugin</artifactId>
199
+                <version>2.4</version>
200
+                <configuration>
201
+                    <archive>
202
+                        <manifest>
203
+                            <addClasspath>true</addClasspath>
204
+                            <classpathPrefix>libs/</classpathPrefix>
205
+                            <mainClass>com.vcarecity.AppRun</mainClass>
206
+                        </manifest>
207
+                    </archive>
208
+                </configuration>
209
+            </plugin>
210
+        </plugins>
211
+    </build>
212
+
213
+</project>

+ 23 - 0
src/main/java/com/vcarecity/AppRun.java 查看文件

@@ -0,0 +1,23 @@
1
+package com.vcarecity;
2
+
3
+import org.springframework.boot.SpringApplication;
4
+import org.springframework.boot.autoconfigure.SpringBootApplication;
5
+import org.springframework.jms.annotation.EnableJms;
6
+import org.springframework.scheduling.annotation.EnableAsync;
7
+import org.springframework.transaction.annotation.EnableTransactionManagement;
8
+import org.springframework.web.bind.annotation.RestController;
9
+
10
+/**
11
+ * @author Zheng Jie
12
+ * @date 2018/11/15 9:20:19
13
+ */
14
+@EnableAsync
15
+@RestController
16
+@SpringBootApplication
17
+@EnableTransactionManagement
18
+@EnableJms    //启动消息队列
19
+public class AppRun {
20
+    public static void main(String[] args) {
21
+        SpringApplication.run(AppRun.class, args);
22
+    }
23
+}

+ 71 - 0
src/main/java/com/vcarecity/mq/config/ActiveMQConfig.java 查看文件

@@ -0,0 +1,71 @@
1
+package com.vcarecity.mq.config;
2
+
3
+import org.apache.activemq.ActiveMQConnectionFactory;
4
+import org.apache.activemq.command.ActiveMQQueue;
5
+import org.apache.activemq.command.ActiveMQTopic;
6
+import org.springframework.beans.factory.annotation.Value;
7
+import org.springframework.context.annotation.Bean;
8
+import org.springframework.context.annotation.Configuration;
9
+import org.springframework.jms.config.JmsListenerContainerFactory;
10
+import org.springframework.jms.config.SimpleJmsListenerContainerFactory;
11
+import org.springframework.jms.core.JmsMessagingTemplate;
12
+
13
+import javax.jms.ConnectionFactory;
14
+import javax.jms.Queue;
15
+import javax.jms.Topic;
16
+
17
+@Configuration
18
+public class ActiveMQConfig {
19
+
20
+    @Value("${spring.activemq.broker-url}")
21
+    private String brokerUrl;
22
+
23
+    @Value("${spring.activemq.user}")
24
+    private String username;
25
+
26
+    @Value("${spring.activemq.topic-name}")
27
+    private String password;
28
+
29
+    @Value("${spring.activemq.queue-name}")
30
+    private String queueName;
31
+
32
+    @Value("${spring.activemq.topic-name}")
33
+    private String topicName;
34
+
35
+    @Bean(name = "queue")
36
+    public Queue queue() {
37
+        return new ActiveMQQueue(queueName);
38
+    }
39
+
40
+    @Bean(name = "topic")
41
+    public Topic topic() {
42
+        return new ActiveMQTopic(topicName);
43
+    }
44
+
45
+    @Bean
46
+    public ConnectionFactory connectionFactory() {
47
+        return new ActiveMQConnectionFactory(username, password, brokerUrl);
48
+    }
49
+
50
+    @Bean
51
+    public JmsMessagingTemplate jmsMessageTemplate() {
52
+        return new JmsMessagingTemplate(connectionFactory());
53
+    }
54
+
55
+    // 在Queue模式中,对消息的监听需要对containerFactory进行配置
56
+    @Bean("queueListener")
57
+    public JmsListenerContainerFactory<?> queueJmsListenerContainerFactory(ConnectionFactory connectionFactory) {
58
+        SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory();
59
+        factory.setConnectionFactory(connectionFactory);
60
+        factory.setPubSubDomain(false);
61
+        return factory;
62
+    }
63
+    //在Topic模式中,对消息的监听需要对containerFactory进行配置
64
+    @Bean("topicListener")
65
+    public JmsListenerContainerFactory<?> topicJmsListenerContainerFactory(ConnectionFactory connectionFactory) {
66
+        SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory();
67
+        factory.setConnectionFactory(connectionFactory);
68
+        factory.setPubSubDomain(true);
69
+        return factory;
70
+    }
71
+}

+ 14 - 0
src/main/java/com/vcarecity/mq/consumer/QueueConsumerListener.java 查看文件

@@ -0,0 +1,14 @@
1
+package com.vcarecity.mq.consumer;
2
+
3
+import org.springframework.jms.annotation.JmsListener;
4
+import org.springframework.stereotype.Component;
5
+
6
+@Component
7
+public class QueueConsumerListener
8
+{
9
+    //queue模式的消费者
10
+    @JmsListener(destination="${spring.activemq.queue-name}", containerFactory="queueListener")
11
+    public void readActiveQueue(String message) {
12
+        System.out.println("queue接收到:" + message);
13
+    }
14
+}

+ 14 - 0
src/main/java/com/vcarecity/mq/consumer/TopicConsumerListener.java 查看文件

@@ -0,0 +1,14 @@
1
+package com.vcarecity.mq.consumer;
2
+
3
+import org.springframework.jms.annotation.JmsListener;
4
+import org.springframework.stereotype.Component;
5
+
6
+@Component
7
+public class TopicConsumerListener
8
+{
9
+    //topic模式的消费者
10
+    @JmsListener(destination="${spring.activemq.topic-name}", containerFactory="topicListener")
11
+    public void readActiveQueue(String message) {
12
+        System.out.println("topic接收到:" + message);
13
+    }
14
+}

+ 45 - 0
src/main/java/com/vcarecity/mq/rest/ProducerController.java 查看文件

@@ -0,0 +1,45 @@
1
+package com.vcarecity.mq.rest;
2
+
3
+import io.swagger.annotations.Api;
4
+import org.springframework.beans.factory.annotation.Autowired;
5
+import org.springframework.jms.core.JmsMessagingTemplate;
6
+import org.springframework.web.bind.annotation.PostMapping;
7
+import org.springframework.web.bind.annotation.RequestBody;
8
+import org.springframework.web.bind.annotation.RequestMapping;
9
+import org.springframework.web.bind.annotation.RestController;
10
+
11
+import javax.jms.Destination;
12
+import javax.jms.Queue;
13
+import javax.jms.Topic;
14
+
15
+@Api(tags = "消息队列:mq")
16
+@RestController
17
+@RequestMapping("/api/mq")
18
+public class ProducerController
19
+{
20
+    @Autowired
21
+    private JmsMessagingTemplate jmsMessagingTemplate;
22
+
23
+    @Autowired
24
+    private Queue queue;
25
+
26
+    @Autowired
27
+    private Topic topic;
28
+
29
+    @PostMapping("/queue/test")
30
+    public String sendQueue(@RequestBody String str) {
31
+        this.sendMessage(this.queue, str);
32
+        return "success";
33
+    }
34
+
35
+    @PostMapping("/topic/test")
36
+    public String sendTopic(@RequestBody String str) {
37
+        this.sendMessage(this.topic, str);
38
+        return "success";
39
+    }
40
+
41
+    // 发送消息,destination是发送到的队列,message是待发送的消息
42
+    private void sendMessage(Destination destination, final String message){
43
+        jmsMessagingTemplate.convertAndSend(destination, message);
44
+    }
45
+}

+ 16 - 0
src/main/java/com/vcarecity/quartz/task/TelNbTokenCheckTask.java 查看文件

@@ -0,0 +1,16 @@
1
+package com.vcarecity.quartz.task;
2
+
3
+import com.vcarecity.util.Symbol;
4
+import com.vcarecity.util.TimeUtil;
5
+import org.springframework.scheduling.annotation.Scheduled;
6
+import org.springframework.stereotype.Component;
7
+
8
+@Component
9
+public class TelNbTokenCheckTask {
10
+    @Scheduled(cron = Symbol.CRON+"10 * * * * ? ")
11
+    public void checkTelNbToken() {
12
+        System.out.println("TimeUtil.getLocalTime():"+ TimeUtil.getLocalTime());
13
+    }
14
+}
15
+
16
+

+ 42 - 0
src/main/java/com/vcarecity/swagger/config/SwaggerConfig.java 查看文件

@@ -0,0 +1,42 @@
1
+package com.vcarecity.swagger.config;
2
+
3
+import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
4
+import org.springframework.context.annotation.Bean;
5
+import org.springframework.context.annotation.Configuration;
6
+import org.springframework.context.annotation.Import;
7
+import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
8
+import springfox.documentation.builders.ApiInfoBuilder;
9
+import springfox.documentation.builders.PathSelectors;
10
+import springfox.documentation.builders.RequestHandlerSelectors;
11
+import springfox.documentation.service.ApiInfo;
12
+import springfox.documentation.service.Contact;
13
+import springfox.documentation.spi.DocumentationType;
14
+import springfox.documentation.spring.web.plugins.Docket;
15
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
16
+
17
+/**
18
+ * 配置
19
+ */
20
+
21
+@Configuration
22
+@EnableSwagger2
23
+@EnableKnife4j
24
+@Import(BeanValidatorPluginsConfiguration.class)
25
+public class SwaggerConfig {
26
+
27
+    @Bean(value = "defaultApi2")
28
+    public Docket defaultApi2() {
29
+        Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
30
+                .select()
31
+                // 这里指定Controller扫描包路径
32
+                .apis(RequestHandlerSelectors.basePackage("com.vcarecity"))
33
+                .paths(PathSelectors.any()).build();
34
+        return docket;
35
+    }
36
+
37
+    private ApiInfo apiInfo() {
38
+        Contact contact = new Contact("pengsn", "", "");
39
+        return new ApiInfoBuilder().title("基本应用接口描述").
40
+                description("基本应用接口描述").contact(contact).version("1.0").build();
41
+    }
42
+}

文件差异内容过多而无法显示
+ 6671 - 0
src/main/java/com/vcarecity/util/StringUtils.java


+ 63 - 0
src/main/java/com/vcarecity/util/Symbol.java 查看文件

@@ -0,0 +1,63 @@
1
+package com.vcarecity.util;
2
+
3
+/**
4
+ * 符号.
5
+ */
6
+public class Symbol
7
+{
8
+    /**
9
+     * %百分号.
10
+     */
11
+    public static final String PERCENT = "%";
12
+
13
+    /**
14
+     * ,逗号.
15
+     */
16
+    public static final String COMMA = ",";
17
+
18
+    /**
19
+     * .点逗号.
20
+     */
21
+    public static final String DOT = ".";
22
+
23
+    /**
24
+     * /斜杠.
25
+     */
26
+    public static final String SLASH = "/";
27
+
28
+    /**
29
+     * -横杠.
30
+     */
31
+    public static final String LINE = "-";
32
+
33
+    /**
34
+     * 空字符串.
35
+     */
36
+    public static final String EMPTY = "";
37
+
38
+    /**
39
+     * _下划线.
40
+     */
41
+    public static final String UNDERLINE = "_";
42
+
43
+    /**
44
+     * !感叹号.
45
+     */
46
+    public static final String EXCLAMATORY_MARK = "!";
47
+
48
+    /**
49
+     * [左方括号.
50
+     */
51
+    public static final String LEFT_SQUARE_BRACKETS = "[";
52
+
53
+    /**
54
+     * ]右方括号.
55
+     */
56
+    public static final String RIGHT_SQUARE_BRACKETS = "]";
57
+
58
+    /**
59
+     *
60
+     */
61
+    public static final String CRON = "*/";
62
+
63
+}

文件差异内容过多而无法显示
+ 1288 - 0
src/main/java/com/vcarecity/util/TimeUtil.java


+ 17 - 0
src/main/resources/application-dev.yml 查看文件

@@ -0,0 +1,17 @@
1
+#配置数据源
2
+spring:
3
+  activemq:
4
+    broker-url: tcp://127.0.0.1:61616
5
+    user: admin
6
+    password: admin
7
+    close-timeout: 15s   # 在考虑结束之前等待的时间
8
+    in-memory: true      # 默认代理URL是否应该在内存中。如果指定了显式代理,则忽略此值。
9
+    non-blocking-redelivery: false  # 是否在回滚回滚消息之前停止消息传递。这意味着当启用此命令时,消息顺序不会被保留。
10
+    send-timeout: 0     # 等待消息发送响应的时间。设置为0等待永远。
11
+    queue-name: active.queue
12
+    topic-name: active.topic.name.model
13
+
14
+  pool:
15
+    enabled: true
16
+    max-connections: 10   #连接池最大连接数
17
+    idle-timeout: 30000   #空闲的连接过期时间,默认为30秒

+ 17 - 0
src/main/resources/application-prod.yml 查看文件

@@ -0,0 +1,17 @@
1
+#配置数据源
2
+spring:
3
+  activemq:
4
+    broker-url: tcp://127.0.0.1:61616
5
+    user: admin
6
+    password: admin
7
+    close-timeout: 15s   # 在考虑结束之前等待的时间
8
+    in-memory: true      # 默认代理URL是否应该在内存中。如果指定了显式代理,则忽略此值。
9
+    non-blocking-redelivery: false  # 是否在回滚回滚消息之前停止消息传递。这意味着当启用此命令时,消息顺序不会被保留。
10
+    send-timeout: 0     # 等待消息发送响应的时间。设置为0等待永远。
11
+    queue-name: active.queue
12
+    topic-name: active.topic.name.model
13
+
14
+  pool:
15
+    enabled: true
16
+    max-connections: 10   #连接池最大连接数
17
+    idle-timeout: 30000   #空闲的连接过期时间,默认为30秒

+ 21 - 0
src/main/resources/application.yml 查看文件

@@ -0,0 +1,21 @@
1
+server:
2
+  port: 9090
3
+
4
+spring:
5
+  freemarker:
6
+    check-template-location: false
7
+  profiles:
8
+    active: dev
9
+  jackson:
10
+    time-zone: GMT+8
11
+
12
+task:
13
+  pool:
14
+    # 核心线程池大小
15
+    core-pool-size: 10
16
+    # 最大线程数
17
+    max-pool-size: 30
18
+    # 活跃时间
19
+    keep-alive-seconds: 60
20
+    # 队列容量
21
+    queue-capacity: 50

+ 8 - 0
src/main/resources/banner.txt 查看文件

@@ -0,0 +1,8 @@
1
+       _                 _           _
2
+      | |               | |         (_)
3
+   ___| |______ __ _  __| |_ __ ___  _ _ __
4
+  / _ | |______/ _` |/ _` | '_ ` _ \| | '_ \
5
+ |  __| |     | (_| | (_| | | | | | | | | | |
6
+  \___|_|      \__,_|\__,_|_| |_| |_|_|_| |_|
7
+
8
+ :: Spring Boot ::       (v2.1.0.RELEASE)

+ 45 - 0
src/main/resources/logback.xml 查看文件

@@ -0,0 +1,45 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<configuration scan="true" scanPeriod="30 seconds" debug="false">
3
+    <contextName>spring-boot-starter-activemq-demo</contextName>
4
+    <property name="log.charset" value="utf-8" />
5
+    <property name="log.pattern" value="%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %gray(%msg%n)" />
6
+
7
+    <!--输出到控制台-->
8
+    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
9
+        <encoder>
10
+            <pattern>${log.pattern}</pattern>
11
+            <charset>${log.charset}</charset>
12
+        </encoder>
13
+    </appender>
14
+
15
+    <!--普通日志输出到控制台-->
16
+    <root level="info">
17
+        <appender-ref ref="console" />
18
+    </root>
19
+
20
+    <!--监控sql日志输出 -->
21
+    <logger name="jdbc.sqlonly" level="INFO" additivity="false">
22
+        <appender-ref ref="console" />
23
+    </logger>
24
+
25
+    <logger name="jdbc.resultset" level="ERROR" additivity="false">
26
+        <appender-ref ref="console" />
27
+    </logger>
28
+
29
+    <!--  如想看到表格数据,将OFF改为INFO  -->
30
+    <logger name="jdbc.resultsettable" level="OFF" additivity="false">
31
+        <appender-ref ref="console" />
32
+    </logger>
33
+
34
+    <logger name="jdbc.connection" level="OFF" additivity="false">
35
+        <appender-ref ref="console" />
36
+    </logger>
37
+
38
+    <logger name="jdbc.sqltiming" level="OFF" additivity="false">
39
+        <appender-ref ref="console" />
40
+    </logger>
41
+
42
+    <logger name="jdbc.audit" level="OFF" additivity="false">
43
+        <appender-ref ref="console" />
44
+    </logger>
45
+</configuration>