引用RocketMQ Spring Boot Starter依赖:
<dependency>
<groupId>com.rhwayfun</groupId>
<artifactId>spring-boot-rocketmq-starter</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
继承自com.rhwayfun.springboot.rocketmq.starter.common.AbstractRocketMqConsumer
使用示例:
@Component
public class DemoRocketMqConsumerExample
extends AbstractRocketMqConsumer<DemoRocketMqTopic, DemoRocketMqTag, DemoRocketMqContent> {
@Override
public Map<String, Set<String>> subscribeTopicTags() {
Map<String, Set<String>> topicSetMap = new HashMap<>();
Set<String> tagSet = new HashSet<>();
tagSet.add("TagA");
tagSet.add("TagB");
topicSetMap.put("TopicA", tagSet);
return topicSetMap;
}
@Override
public boolean handle(String topic, String tag, DemoRocketMqContent content, MessageExt msg) {
logger.info("receive msg[{}], topic:{}, tag:{}, content:{}", msg, topic, tag, content);
return true;
}
}
待补充。。。