Skip to content

Commit

Permalink
Merge branch 'dev-1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
metaphysical-road committed Jun 26, 2023
2 parents 2d0b17f + 1a85022 commit f93306f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>

<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-dubbo</artifactId>
Expand All @@ -40,11 +46,13 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -76,6 +84,12 @@
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-spring-boot-starter</artifactId>
<version>2.2.0</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

/**
* 第一种消费消息模式:监听器自动消费消息
* 第二种消费消息的模式:RocketMQTemplate模式
* 线上只允许使用一种
*/
@SpringBootApplication
@EnableDiscoveryClient
public class UseSpringBootConsumeApplication {
public class
UseSpringBootConsumeApplication {
public static void main(String[] args) {
SpringApplication.run(UseSpringBootConsumeApplication.class, args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public void startConsume(){
executorService.submit(new ConsumeMessage());
}

/**
* 第二种消费消息的模式:RocketMQTemplate模式
*/
class ConsumeMessage implements Runnable {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
@Service
@RocketMQMessageListener(topic = "${rocketmq.consumer.topic}", consumerGroup = "use-spring-boot-access-rocketmq")
public class StringConsumer implements RocketMQListener<String> {

/**
* 第一种消费消息模式:监听器自动消费消息
* @param message
*/
@Override
public void onMessage(String message) {
System.out.printf("------- StringConsumer received: %s \n", message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,19 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -77,6 +85,12 @@
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-spring-boot-starter</artifactId>
<version>2.2.0</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

0 comments on commit f93306f

Please sign in to comment.