Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions rocketmq-v5-client-spring-boot-samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-v5-client-spring-boot-samples</artifactId>
<packaging>pom</packaging>
<version>2.3.2-SNAPSHOT</version>
<version>2.3.6-SNAPSHOT</version>

<name>rocketmq-v5-client-spring-boot-samples</name>
<description>rocketmq-v5-client-spring-boot-samples</description>
Expand All @@ -35,7 +35,9 @@
<module>rocketmq-v5-client-producer-simple-demo</module>
<module>rocketmq-v5-client-consumer-simple-demo</module>
<module>rocketmq-v5-client-consumer-push-simple-demo</module>
</modules>
<module>rocketmq-v5-client-consume-simple-subscribe-muliti-topic-demo</module>
<module>rocketmq-v5-client-consume-simple-subscribe-muliti-topic-demo</module>
</modules>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-v5-client-spring-boot-samples</artifactId>
<version>2.3.2-SNAPSHOT</version>
<version>2.3.6-SNAPSHOT</version>
</parent>
<artifactId>rocketmq-v5-client-consume-acl-demo</artifactId>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-v5-client-spring-boot-samples</artifactId>
<version>2.3.2-SNAPSHOT</version>
<version>2.3.6-SNAPSHOT</version>
</parent>

<artifactId>rocketmq-v5-client-consume-demo</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-v5-client-spring-boot-samples</artifactId>
<version>2.3.6-SNAPSHOT</version>
</parent>

<artifactId>rocketmq-v5-client-consume-simple-subscribe-muliti-topic-demo</artifactId>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.rocketmq.springboot;

import org.apache.rocketmq.client.annotation.ExtConsumerResetConfiguration;
import org.apache.rocketmq.client.core.RocketMQClientTemplate;

@ExtConsumerResetConfiguration(subscriptionExpressions = {
@ExtConsumerResetConfiguration.FilterExpression(topic = "demo-topic", tag = "tagA", filterExpressionType = "tag"),
@ExtConsumerResetConfiguration.FilterExpression(topic = "demo-topic2", tag = "tagB", filterExpressionType = "tag")
})
public class ExtRocketMQTemplate extends RocketMQClientTemplate {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.rocketmq.springboot;

import org.apache.rocketmq.client.apis.message.MessageView;
import org.apache.rocketmq.client.core.RocketMQClientTemplate;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.Resource;
import java.time.Duration;
import java.util.List;

@SpringBootApplication
public class V5SimpleConsumerConsumerApplication implements CommandLineRunner {
@Resource
private RocketMQClientTemplate rocketMQClientTemplate;

@Resource
private ExtRocketMQTemplate extRocketMQTemplate;

public static void main(String[] args) {
SpringApplication.run(V5SimpleConsumerConsumerApplication.class, args);
}

@Override
public void run(String... args) throws Exception {
while (true){
List<MessageView> messageList = extRocketMQTemplate.receive(10, Duration.ofSeconds(10));
System.out.println(messageList);

messageList = rocketMQClientTemplate.receive(10, Duration.ofSeconds(10));
System.out.println(messageList);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

rocketmq.simple-consumer.endpoints=localhost:8080
rocketmq.simple-consumer.consumer-group=test-group
rocketmq.simple-consumer.subscription-expressions.demo-topic.tag=tagA
rocketmq.simple-consumer.subscription-expressions.demo-topic.filter-expression-type=tag
rocketmq.simple-consumer.subscription-expressions.demo-topic2.tag=tagB
rocketmq.simple-consumer.subscription-expressions.demo-topic2.filter-expression-type=tag
#rocketmq.simple-consumer.access-key=
#rocketmq.simple-consumer.secret-key=
#rocketmq.simple-consumer.namespace=

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-v5-client-spring-boot-samples</artifactId>
<version>2.3.2-SNAPSHOT</version>
<version>2.3.6-SNAPSHOT</version>
</parent>

<artifactId>rocketmq-v5-client-consumer-push-simple-demo</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-v5-client-spring-boot-samples</artifactId>
<version>2.3.2-SNAPSHOT</version>
<version>2.3.6-SNAPSHOT</version>
</parent>

<artifactId>rocketmq-v5-client-consumer-simple-demo</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-v5-client-spring-boot-samples</artifactId>
<version>2.3.2-SNAPSHOT</version>
<version>2.3.6-SNAPSHOT</version>
</parent>

<artifactId>rocketmq-v5-client-producer-acl-demo</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-v5-client-spring-boot-samples</artifactId>
<version>2.3.2-SNAPSHOT</version>
<version>2.3.6-SNAPSHOT</version>
</parent>

<artifactId>rocketmq-v5-client-producer-demo</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-v5-client-spring-boot-samples</artifactId>
<version>2.3.2-SNAPSHOT</version>
<version>2.3.6-SNAPSHOT</version>
</parent>

<artifactId>rocketmq-v5-client-producer-simple-demo</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions rocketmq-v5-client-spring-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
</dependencies>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,28 @@
* The namespace of consumer.
*/
String namespace() default "";

/**
* subscribing to multiple topics
*/
FilterExpression[] subscriptionExpressions() default {};

@Retention(RetentionPolicy.RUNTIME)
@Target({})
@interface FilterExpression {
/**
* Topic name of consumer.
*/
String topic();

/**
* Tag of consumer.
*/
String tag() default "*";

/**
* The type of filter expression
*/
String filterExpressionType() default "tag";
}
}
Loading
Loading