Skip to content

Commit

Permalink
modify RocketmqTopicCore, using SDKManager
Browse files Browse the repository at this point in the history
  • Loading branch information
scwlkq committed Mar 17, 2024
1 parent 7c7981d commit 6a15405
Show file tree
Hide file tree
Showing 29 changed files with 387 additions and 247 deletions.
33 changes: 33 additions & 0 deletions eventmesh-dashboard-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,39 @@
<artifactId>fastjson2</artifactId>
<version>2.0.40</version>
</dependency>
<!-- storage redis client -->
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
</dependency>
<!-- Meta - nacos client -->
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>${nacos.version}</version>
</dependency>
<!-- Unit Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
<!-- rocketmq client -->
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>${rocketmq.version}</version>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-tools</artifactId>
<version>${rocketmq.version}</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.eventmesh.dashboard.common.properties;

import lombok.Data;

@Data
public class RocketmqProperties {

private String namesrvAddr;

private String clusterName;

private String brokerUrl;

private String endPoint;

private int writeQueueNums = 8;

private int readQueueNums = 8;

private String accessKey;

private String secretKey;

private long requestTimeoutMillis = 10000L;
}
38 changes: 1 addition & 37 deletions eventmesh-dashboard-console/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@
<scope>runtime</scope>
</dependency>

<!-- Meta - nacos client -->
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>${nacos.version}</version>
</dependency>

<!-- health check client -->
<!-- EventMesh SDK -->
<!-- <dependency>-->
Expand All @@ -93,38 +86,9 @@
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<!-- storage redis client -->
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
</dependency>
<!-- rocketmq client -->
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>4.9.4</version>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-tools</artifactId>
<version>5.2.0</version>
</dependency>
<!-- health check client end -->

<!-- Unit Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<!-- TODO: remove junit4 dependency -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<!-- health check client end -->
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.eventmesh.dashboard.console.controller;

import org.apache.eventmesh.dashboard.common.dto.Result;
import org.apache.eventmesh.dashboard.common.model.TopicProperties;
import org.apache.eventmesh.dashboard.service.dto.TopicProperties;
import org.apache.eventmesh.dashboard.console.dto.CreateTopicRequest;
import org.apache.eventmesh.dashboard.console.dto.DeleteTopicRequest;
import org.apache.eventmesh.dashboard.service.store.TopicCore;
Expand Down Expand Up @@ -59,22 +59,22 @@ public ResponseEntity<Object> preflight() {
}

@CrossOrigin
@GetMapping
@GetMapping("/getList")
public Result<List<TopicProperties>> getList() {
List<TopicProperties> topicList = topicCore.getTopic();
List<TopicProperties> topicList = topicCore.getTopics();
return Result.success(topicList);
}

@CrossOrigin
@PostMapping
@PostMapping("/create")
public Result<Object> create(@RequestBody CreateTopicRequest createTopicRequest) {
String topicName = createTopicRequest.getName();
topicCore.createTopic(topicName);
return Result.success();
}

@CrossOrigin
@DeleteMapping
@DeleteMapping("delete")
public Result<Object> delete(@RequestBody DeleteTopicRequest deleteTopicRequest) {
String topicName = deleteTopicRequest.getName();
topicCore.deleteTopic(topicName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback;
import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService;
import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
import org.apache.eventmesh.dashboard.service.store.TopicCore;

import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.SDK;
package org.apache.eventmesh.dashboard.core.function.SDK;

public abstract class AbstractSDKOperation<T> implements SDKOperation<T> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,25 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.SDK;
package org.apache.eventmesh.dashboard.core.function.SDK;

import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateSDKConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.operation.NacosConfigSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.operation.NacosNamingSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.operation.NacosSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.operation.RedisSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.operation.RocketMQProduceSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.operation.RocketMQPushConsumerSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.operation.RocketMQRemotingSDKOperation;
import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig;
import org.apache.eventmesh.dashboard.core.function.SDK.operation.NacosConfigSDKOperation;
import org.apache.eventmesh.dashboard.core.function.SDK.operation.NacosNamingSDKOperation;
import org.apache.eventmesh.dashboard.core.function.SDK.operation.NacosSDKOperation;
import org.apache.eventmesh.dashboard.core.function.SDK.operation.RedisSDKOperation;
import org.apache.eventmesh.dashboard.core.function.SDK.operation.RocketMQProduceSDKOperation;
import org.apache.eventmesh.dashboard.core.function.SDK.operation.RocketMQPushConsumerSDKOperation;
import org.apache.eventmesh.dashboard.core.function.SDK.operation.RocketMQRemotingSDKOperation;

import java.util.AbstractMap.SimpleEntry;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;



/**
* SDK manager is a singleton to manage all SDK clients, it is a facade to create, delete and get a client.
*/
public class SDKManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.SDK;
package org.apache.eventmesh.dashboard.core.function.SDK;

import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateSDKConfig;
import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig;

import java.util.AbstractMap.SimpleEntry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.SDK;
package org.apache.eventmesh.dashboard.core.function.SDK;

public enum SDKTypeEnum {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.SDK.config;
package org.apache.eventmesh.dashboard.core.function.SDK.config;

import lombok.Data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.SDK.config;
package org.apache.eventmesh.dashboard.core.function.SDK.config;

import lombok.Data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.SDK.config;
package org.apache.eventmesh.dashboard.core.function.SDK.config;

import org.apache.rocketmq.client.consumer.listener.MessageListener;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.SDK.config;
package org.apache.eventmesh.dashboard.core.function.SDK.config;

/**
* Config to create an SDK client, usually contains an address url.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.SDK.operation;
package org.apache.eventmesh.dashboard.core.function.SDK.operation;

import org.apache.eventmesh.dashboard.console.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateSDKConfig;
import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig;

import java.util.AbstractMap.SimpleEntry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.SDK.operation;
package org.apache.eventmesh.dashboard.core.function.SDK.operation;

import org.apache.eventmesh.dashboard.console.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateNacosConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateSDKConfig;
import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateNacosConfig;
import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig;

import java.util.AbstractMap.SimpleEntry;
import java.util.Properties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.SDK.operation;
package org.apache.eventmesh.dashboard.core.function.SDK.operation;

import org.apache.eventmesh.dashboard.console.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateNacosConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateSDKConfig;
import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateNacosConfig;
import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig;

import java.util.AbstractMap.SimpleEntry;
import java.util.Properties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.SDK.operation;
package org.apache.eventmesh.dashboard.core.function.SDK.operation;

import org.apache.eventmesh.dashboard.console.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateSDKConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.wrapper.NacosSDKWrapper;
import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig;
import org.apache.eventmesh.dashboard.core.function.SDK.wrapper.NacosSDKWrapper;

import java.util.AbstractMap.SimpleEntry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.SDK.operation;
package org.apache.eventmesh.dashboard.core.function.SDK.operation;

import org.apache.eventmesh.dashboard.console.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateRedisConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateSDKConfig;
import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRedisConfig;
import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig;

import java.util.AbstractMap.SimpleEntry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.SDK.operation;
package org.apache.eventmesh.dashboard.core.function.SDK.operation;

import org.apache.eventmesh.dashboard.console.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateRocketmqConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateSDKConfig;
import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRocketmqConfig;
import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig;

import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.SDK.operation;
package org.apache.eventmesh.dashboard.core.function.SDK.operation;

import org.apache.eventmesh.dashboard.console.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateRocketmqConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateSDKConfig;
import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRocketmqConfig;
import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig;

import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.exception.MQClientException;
Expand Down
Loading

0 comments on commit 6a15405

Please sign in to comment.