Skip to content

Commit 71d84b8

Browse files
authored
Support simple consumer supports subscribing to multiple topics (#772)
* support simple consumer supports subscribing to multiple topics * support simple consumer supports subscribing to multiple topics * support simple consumer supports subscribing to multiple topics * support simple consumer supports subscribing to multiple topics * support simple consumer supports subscribing to multiple topics
1 parent 1eb3bed commit 71d84b8

18 files changed

Lines changed: 277 additions & 43 deletions

File tree

‎rocketmq-v5-client-spring-boot-samples/pom.xml‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<groupId>org.apache.rocketmq</groupId>
2323
<artifactId>rocketmq-v5-client-spring-boot-samples</artifactId>
2424
<packaging>pom</packaging>
25-
<version>2.3.2-SNAPSHOT</version>
25+
<version>2.3.6-SNAPSHOT</version>
2626

2727
<name>rocketmq-v5-client-spring-boot-samples</name>
2828
<description>rocketmq-v5-client-spring-boot-samples</description>
@@ -35,7 +35,9 @@
3535
<module>rocketmq-v5-client-producer-simple-demo</module>
3636
<module>rocketmq-v5-client-consumer-simple-demo</module>
3737
<module>rocketmq-v5-client-consumer-push-simple-demo</module>
38-
</modules>
38+
<module>rocketmq-v5-client-consume-simple-subscribe-muliti-topic-demo</module>
39+
<module>rocketmq-v5-client-consume-simple-subscribe-muliti-topic-demo</module>
40+
</modules>
3941

4042
<properties>
4143
<maven.compiler.source>1.8</maven.compiler.source>

‎rocketmq-v5-client-spring-boot-samples/rocketmq-v5-client-consume-acl-demo/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>org.apache.rocketmq</groupId>
2323
<artifactId>rocketmq-v5-client-spring-boot-samples</artifactId>
24-
<version>2.3.2-SNAPSHOT</version>
24+
<version>2.3.6-SNAPSHOT</version>
2525
</parent>
2626
<artifactId>rocketmq-v5-client-consume-acl-demo</artifactId>
2727

‎rocketmq-v5-client-spring-boot-samples/rocketmq-v5-client-consume-demo/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>org.apache.rocketmq</groupId>
2323
<artifactId>rocketmq-v5-client-spring-boot-samples</artifactId>
24-
<version>2.3.2-SNAPSHOT</version>
24+
<version>2.3.6-SNAPSHOT</version>
2525
</parent>
2626

2727
<artifactId>rocketmq-v5-client-consume-demo</artifactId>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one or more
4+
~ contributor license agreements. See the NOTICE file distributed with
5+
~ this work for additional information regarding copyright ownership.
6+
~ The ASF licenses this file to You under the Apache License, Version 2.0
7+
~ (the "License"); you may not use this file except in compliance with
8+
~ the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
-->
18+
<project xmlns="http://maven.apache.org/POM/4.0.0"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
<parent>
23+
<groupId>org.apache.rocketmq</groupId>
24+
<artifactId>rocketmq-v5-client-spring-boot-samples</artifactId>
25+
<version>2.3.6-SNAPSHOT</version>
26+
</parent>
27+
28+
<artifactId>rocketmq-v5-client-consume-simple-subscribe-muliti-topic-demo</artifactId>
29+
30+
<properties>
31+
<maven.compiler.source>8</maven.compiler.source>
32+
<maven.compiler.target>8</maven.compiler.target>
33+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
34+
</properties>
35+
36+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.rocketmq.springboot;
18+
19+
import org.apache.rocketmq.client.annotation.ExtConsumerResetConfiguration;
20+
import org.apache.rocketmq.client.core.RocketMQClientTemplate;
21+
22+
@ExtConsumerResetConfiguration(subscriptionExpressions = {
23+
@ExtConsumerResetConfiguration.FilterExpression(topic = "demo-topic", tag = "tagA", filterExpressionType = "tag"),
24+
@ExtConsumerResetConfiguration.FilterExpression(topic = "demo-topic2", tag = "tagB", filterExpressionType = "tag")
25+
})
26+
public class ExtRocketMQTemplate extends RocketMQClientTemplate {
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.rocketmq.springboot;
19+
20+
import org.apache.rocketmq.client.apis.message.MessageView;
21+
import org.apache.rocketmq.client.core.RocketMQClientTemplate;
22+
import org.springframework.boot.CommandLineRunner;
23+
import org.springframework.boot.SpringApplication;
24+
import org.springframework.boot.autoconfigure.SpringBootApplication;
25+
26+
import javax.annotation.Resource;
27+
import java.time.Duration;
28+
import java.util.List;
29+
30+
@SpringBootApplication
31+
public class V5SimpleConsumerConsumerApplication implements CommandLineRunner {
32+
@Resource
33+
private RocketMQClientTemplate rocketMQClientTemplate;
34+
35+
@Resource
36+
private ExtRocketMQTemplate extRocketMQTemplate;
37+
38+
public static void main(String[] args) {
39+
SpringApplication.run(V5SimpleConsumerConsumerApplication.class, args);
40+
}
41+
42+
@Override
43+
public void run(String... args) throws Exception {
44+
while (true){
45+
List<MessageView> messageList = extRocketMQTemplate.receive(10, Duration.ofSeconds(10));
46+
System.out.println(messageList);
47+
48+
messageList = rocketMQClientTemplate.receive(10, Duration.ofSeconds(10));
49+
System.out.println(messageList);
50+
}
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
rocketmq.simple-consumer.endpoints=localhost:8080
17+
rocketmq.simple-consumer.consumer-group=test-group
18+
rocketmq.simple-consumer.subscription-expressions.demo-topic.tag=tagA
19+
rocketmq.simple-consumer.subscription-expressions.demo-topic.filter-expression-type=tag
20+
rocketmq.simple-consumer.subscription-expressions.demo-topic2.tag=tagB
21+
rocketmq.simple-consumer.subscription-expressions.demo-topic2.filter-expression-type=tag
22+
#rocketmq.simple-consumer.access-key=
23+
#rocketmq.simple-consumer.secret-key=
24+
#rocketmq.simple-consumer.namespace=
25+

‎rocketmq-v5-client-spring-boot-samples/rocketmq-v5-client-consumer-push-simple-demo/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<groupId>org.apache.rocketmq</groupId>
2424
<artifactId>rocketmq-v5-client-spring-boot-samples</artifactId>
25-
<version>2.3.2-SNAPSHOT</version>
25+
<version>2.3.6-SNAPSHOT</version>
2626
</parent>
2727

2828
<artifactId>rocketmq-v5-client-consumer-push-simple-demo</artifactId>

‎rocketmq-v5-client-spring-boot-samples/rocketmq-v5-client-consumer-simple-demo/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<groupId>org.apache.rocketmq</groupId>
2424
<artifactId>rocketmq-v5-client-spring-boot-samples</artifactId>
25-
<version>2.3.2-SNAPSHOT</version>
25+
<version>2.3.6-SNAPSHOT</version>
2626
</parent>
2727

2828
<artifactId>rocketmq-v5-client-consumer-simple-demo</artifactId>

‎rocketmq-v5-client-spring-boot-samples/rocketmq-v5-client-producer-acl-demo/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>org.apache.rocketmq</groupId>
2323
<artifactId>rocketmq-v5-client-spring-boot-samples</artifactId>
24-
<version>2.3.2-SNAPSHOT</version>
24+
<version>2.3.6-SNAPSHOT</version>
2525
</parent>
2626

2727
<artifactId>rocketmq-v5-client-producer-acl-demo</artifactId>

0 commit comments

Comments
 (0)