Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

提交一下 #1

Merged
merged 5 commits into from
Jan 6, 2022
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
4 changes: 4 additions & 0 deletions examples/cluster-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
<groupId>group.idealworld.dew</groupId>
<artifactId>cluster-spi-redis</artifactId>
</dependency>
<dependency>
<groupId>group.idealworld.dew</groupId>
<artifactId>cluster-spi-rocket</artifactId>
</dependency>
<!--<dependency>
<groupId>group.idealworld.dew</groupId>
<artifactId>cluster-spi-hazelcast</artifactId>
Expand Down
65 changes: 65 additions & 0 deletions framework/modules/cluster-rocket/pom.xml
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>
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);

}
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);

}
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);

}
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;
}





}
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);
}

}
Loading