-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #184 from starsys-tech/master
Add support for rocketmq.
- Loading branch information
Showing
17 changed files
with
715 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright 2021. the original author or authors. | ||
~ | ||
~ 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. | ||
--> | ||
|
||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
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>group.idealworld.dew</groupId> | ||
<artifactId>parent-starter</artifactId> | ||
<version>3.0.0-Beta3</version> | ||
<relativePath>../parent-starter</relativePath> | ||
</parent> | ||
|
||
<artifactId>cluster-spi-rocket</artifactId> | ||
<name>1.1.4 Dew Cluster Rocket</name> | ||
<description>Dew 集群 Rocket 实现</description> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>group.idealworld.dew</groupId> | ||
<artifactId>cluster-common</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.rocketmq</groupId> | ||
<artifactId>rocketmq-spring-boot-starter</artifactId> | ||
<version>${rocket.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>group.idealworld.dew</groupId> | ||
<artifactId>cluster-common-test</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>group.idealworld.dew</groupId> | ||
<artifactId>test-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-autoconfigure</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>group.idealworld.dew</groupId> | ||
<artifactId>test-starter</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
28 changes: 28 additions & 0 deletions
28
...r-rocket/src/main/java/group/idealworld/dew/core/cluster/spi/rocket/ReceiveBeforeFun.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2020. the original author or authors. | ||
* | ||
* 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 group.idealworld.dew.core.cluster.spi.rocket; | ||
|
||
|
||
import java.util.Map; | ||
|
||
@FunctionalInterface | ||
public interface ReceiveBeforeFun { | ||
|
||
|
||
Object invoke(String topic, Map<String,Object> properties); | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...er-rocket/src/main/java/group/idealworld/dew/core/cluster/spi/rocket/ReceiveErrorFun.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2020. the original author or authors. | ||
* | ||
* 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 group.idealworld.dew.core.cluster.spi.rocket; | ||
|
||
|
||
@FunctionalInterface | ||
public interface ReceiveErrorFun { | ||
|
||
/** | ||
* Invoke. | ||
* | ||
* @param ex the ex | ||
* @param beforeResult the before result | ||
*/ | ||
void invoke(Exception ex, Object beforeResult); | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...r-rocket/src/main/java/group/idealworld/dew/core/cluster/spi/rocket/ReceiveFinishFun.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2020. the original author or authors. | ||
* | ||
* 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 group.idealworld.dew.core.cluster.spi.rocket; | ||
|
||
|
||
@FunctionalInterface | ||
public interface ReceiveFinishFun { | ||
|
||
/** | ||
* Invoke. | ||
* | ||
* @param beforeResult the before result | ||
*/ | ||
void invoke(Object beforeResult); | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...ster-rocket/src/main/java/group/idealworld/dew/core/cluster/spi/rocket/RocketAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2020. the original author or authors. | ||
* | ||
* 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 group.idealworld.dew.core.cluster.spi.rocket; | ||
|
||
import org.apache.rocketmq.client.producer.DefaultMQProducer; | ||
import org.apache.rocketmq.spring.core.RocketMQTemplate; | ||
|
||
/** | ||
* Rocket adapter. | ||
* | ||
* @author nipeixuan | ||
*/ | ||
public class RocketAdapter { | ||
|
||
private RocketMQTemplate rocketMQTemplate; | ||
|
||
/** | ||
* Instantiates a new Rabbit adapter. | ||
* | ||
* @param rocketMQTemplate the rabbit template | ||
*/ | ||
public RocketAdapter(RocketMQTemplate rocketMQTemplate) { | ||
this.rocketMQTemplate = rocketMQTemplate; | ||
} | ||
|
||
DefaultMQProducer getProducer(){ | ||
return rocketMQTemplate.getProducer(); | ||
} | ||
|
||
RocketMQTemplate getRocketMQTemplate(){ | ||
return this.rocketMQTemplate; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
} |
78 changes: 78 additions & 0 deletions
78
...t/src/main/java/group/idealworld/dew/core/cluster/spi/rocket/RocketAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright 2020. the original author or authors. | ||
* | ||
* 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 group.idealworld.dew.core.cluster.spi.rocket; | ||
|
||
import org.apache.rocketmq.spring.core.RocketMQTemplate; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.validation.Valid; | ||
|
||
/** | ||
* rocket auto configuration. | ||
* | ||
* @author nipeixuan | ||
*/ | ||
@Configuration | ||
@ConditionalOnClass(RocketMQTemplate.class) | ||
@ConditionalOnExpression("#{'${dew.cluster.mq}'=='rocket'}") | ||
public class RocketAutoConfiguration { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(RocketAutoConfiguration.class); | ||
|
||
@Value("${rocketmq.producer.group}") | ||
private String groupName; | ||
|
||
@Value("${rocketmq.name-server}") | ||
private String nameServer; | ||
|
||
|
||
@PostConstruct | ||
public void init() { | ||
logger.info("Load Auto Configuration : {}", this.getClass().getName()); | ||
} | ||
|
||
/** | ||
* Rabbit adapter. | ||
* | ||
* @param rocketMQTemplate the rocket template | ||
* @return the rocket adapter | ||
*/ | ||
@Bean | ||
public RocketAdapter rocketAdapter(RocketMQTemplate rocketMQTemplate) { | ||
return new RocketAdapter(rocketMQTemplate); | ||
} | ||
|
||
/** | ||
* Rocket cluster mq. | ||
* | ||
* @param rocketAdapter the rocket adapter | ||
* @return the rocket cluster mq | ||
*/ | ||
@Bean | ||
@ConditionalOnExpression("'${dew.cluster.mq}'=='rocket'") | ||
public RocketClusterMQ rocketClusterMQ(RocketAdapter rocketAdapter) { | ||
return new RocketClusterMQ(rocketAdapter, nameServer, groupName); | ||
} | ||
|
||
} |
Oops, something went wrong.