Skip to content

Commit

Permalink
Merge pull request #1599 from chengyouling/develop-mq-gray
Browse files Browse the repository at this point in the history
add rocketMq message gray plugin
  • Loading branch information
Sherlockhan authored Aug 31, 2024
2 parents 1f689e7 + 073a298 commit c5d5819
Show file tree
Hide file tree
Showing 16 changed files with 1,401 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ plugins:
- service-visibility
- tag-transmission
- database-write-prohibition
- mq-grayscale
# 'dynamicPlugins' is used to configure plugins that support dynamic installation. The plugins take effect when Sermant starts by agentmain. allows uninstallation:
# 1. active plugins will be actively enabled
# 2. passive plugins need to be enabled by commands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ plugins:
- service-visibility
- tag-transmission
- database-write-prohibition
- mq-grayscale
# 'dynamicPlugins' is used to configure plugins that support dynamic installation. The plugins take effect when Sermant starts by agentmain. allows uninstallation:
# 1. active plugins will be actively enabled
# 2. passive plugins need to be enabled by commands
Expand Down
3 changes: 3 additions & 0 deletions sermant-plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<module>sermant-spring-beans-deal</module>
<module>sermant-tag-transmission</module>
<module>sermant-database-write-prohibition</module>
<module>sermant-mq-grayscale</module>
</modules>
<build>
<pluginManagement>
Expand Down Expand Up @@ -76,6 +77,7 @@
<module>sermant-spring-beans-deal</module>
<module>sermant-tag-transmission</module>
<module>sermant-database-write-prohibition</module>
<module>sermant-mq-grayscale</module>
</modules>
<build>
<pluginManagement>
Expand Down Expand Up @@ -109,6 +111,7 @@
<module>sermant-spring-beans-deal</module>
<module>sermant-tag-transmission</module>
<module>sermant-database-write-prohibition</module>
<module>sermant-mq-grayscale</module>
</modules>
</profile>
</profiles>
Expand Down
33 changes: 33 additions & 0 deletions sermant-plugins/sermant-mq-grayscale/config/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Configuration of MQ message grayscale
grayscale.mq.config:
# Whether to enable message grayscale. The default value is false
enabled: false
# Gray group information definition, each group contains consumerGroupTag、serviceMeta、trafficTag info.
grayscale:
# Gray consumer group tag. example, base group is basic_group, then gray group is basic_group_${consumerGroupTag}
- consumerGroupTag: gray
serviceMeta:
# ServiceMeta match tag, if service_meta_parameters set x_lane_tag:gray, then current consumer is gray node.
# If using service_meta_version for match info, config key must is 'version', as version:1.0.1
x_lane_tag: gray
version: 1.0.1
trafficTag:
# Traffic match info, this config effective with sermant-tag-transmission plugin, if request header has
# x_lane_canary=gray and tag.transmission.config.matchRule.exact: ['x_lane_canary'], then will set as gray message
x_lane_canary: gray
# The relationship between serviceMeta and trafficTag is as follows:
# If service_meta_parameters set x_lane_tag:gray when service started, then will match as gray instance.
# 1、As producer, produce message will put 'x_lane_canary: gray' in message property as gray message.
# 2、As consumer, only consume with 'x_lane_canary: gray' property messages.
# Base group information definition
base:
# Base group consume message mode, contains BASE/AUTO, default 'AUTO'
# BASE mode consumer will consume message that out of excludeGroupTags corresponding consumer group
# AUTO mode consumer will consume message that out of excludeGroupTags corresponding consumer group and other
# Running gray consumer group
consumeMode: AUTO
# Interval for checking gray consumer group information in auto consumer type
autoCheckDelayTime: 15
# Tag of the gray consumer group to be excluded, corresponding value is above consumerGroupTag value
# Auto/base consume mode all effective
excludeGroupTags: ["gray"]
60 changes: 60 additions & 0 deletions sermant-plugins/sermant-mq-grayscale/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<artifactId>sermant-plugins</artifactId>
<groupId>io.sermant</groupId>
<version>1.0.0</version>
</parent>

<artifactId>sermant-mq-grayscale</artifactId>
<name>sermant-mq-grayscale</name>
<packaging>pom</packaging>

<properties>
<sermant.basedir>${pom.basedir}/../../..</sermant.basedir>
<package.plugin.name>mq-grayscale</package.plugin.name>
<rocketmq-client.version>5.0.0</rocketmq-client.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>${rocketmq-client.version}</version>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-common</artifactId>
<version>${rocketmq-client.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

<profiles>
<profile>
<id>agent</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>
<module>sermant-mq-grayscale-plugin</module>
</modules>
</profile>
<profile>
<id>test</id>
<modules>
<module>sermant-mq-grayscale-plugin</module>
</modules>
</profile>
<profile>
<id>release</id>
<modules>
<module>sermant-mq-grayscale-plugin</module>
</modules>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<artifactId>sermant-mq-grayscale</artifactId>
<groupId>io.sermant</groupId>
<version>1.0.0</version>
</parent>

<artifactId>sermant-mq-grayscale-plugin</artifactId>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<config.skip.flag>false</config.skip.flag>
<package.plugin.type>plugin</package.plugin.type>
</properties>

<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</dependency>
<dependency>
<groupId>io.sermant</groupId>
<artifactId>sermant-agentcore-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-common</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (C) 2024-2024 Sermant Authors. All rights reserved.
*
* Licensed 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 io.sermant.mq.grayscale.config;

import java.util.ArrayList;
import java.util.List;

/**
* base consume mode entity
*
* @author chengyouling
* @since 2024-05-27
**/
public class BaseMessage {
/**
* default value
*/
private static final long DEFAULT = 15L;

private ConsumeModeEnum consumeMode = ConsumeModeEnum.AUTO;

private long autoCheckDelayTime = DEFAULT;

private List<String> excludeGroupTags = new ArrayList<>();

public ConsumeModeEnum getConsumeMode() {
return consumeMode;
}

public void setConsumeMode(ConsumeModeEnum consumeMode) {
this.consumeMode = consumeMode;
}

public long getAutoCheckDelayTime() {
return autoCheckDelayTime;
}

public void setAutoCheckDelayTime(long autoCheckDelayTime) {
this.autoCheckDelayTime = autoCheckDelayTime;
}

public List<String> getExcludeGroupTags() {
return excludeGroupTags;
}

public void setExcludeGroupTags(List<String> excludeGroupTags) {
this.excludeGroupTags = excludeGroupTags;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (C) 2024-2024 Sermant Authors. All rights reserved.
*
* Licensed 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 io.sermant.mq.grayscale.config;

/**
* consume mode entity
*
* @author chengyouling
* @since 2024-05-27
**/
public enum ConsumeModeEnum {
/**
* auto consume mode
*/
AUTO,

/**
* base consume mode
*/
BASE
}
Loading

0 comments on commit c5d5819

Please sign in to comment.