Browse Source

框架融合dubbo与zookeeper作为rpc框架.

NorthLan 7 years ago
parent
commit
982092f2d6

+ 7 - 2
build.gradle

@@ -28,7 +28,8 @@ buildscript {
 //        kisso_version = '3.6.13'
         caffeine_version = '2.6.1'
         shiro_version = '1.4.0'
-        dubbo_starter_version = '2.0.0'
+        dubbo_starter_version = '0.1.0'
+        dubbo_version = "2.6.1"
     }
     repositories {
         mavenCentral()
@@ -121,7 +122,11 @@ subprojects {
         compile('com.github.shihyuho:jackson-dynamic-filter:1.0')
 
         // rpc
-        compile('com.alibaba.spring.boot:dubbo-spring-boot-starter:$dubbo_starter_version')
+        compile("com.alibaba.boot:dubbo-spring-boot-starter:$dubbo_starter_version")
+                {
+                    exclude group: "com.alibaba", module: "dubbo"
+                }
+        compile("com.alibaba:dubbo:$dubbo_version")
 
         // activiti
 //        compile("org.activiti:activiti-spring-boot-starter-basic:$activiti_starter_version")

+ 2 - 1
zen-api/src/main/kotlin/com/gxzc/zen/api/sys/common/MenuTree.kt

@@ -10,8 +10,9 @@ import com.gxzc.zen.common.util.common.TreeNode
  */
 class MenuTree : TreeNode() {
     companion object {
-        private const val serialVersionUID = 5640224091610000005L
+        const val serialVersionUID = 5640224091610000005L
     }
+
     /**
      * 菜单编码
      */

+ 1 - 1
zen-core/src/main/kotlin/com/gxzc/zen/common/util/common/TreeNode.kt

@@ -10,7 +10,7 @@ import java.io.Serializable
  */
 open class TreeNode : Serializable {
     companion object {
-        private const val serialVersionUID = 5640224091610000001L
+        const val serialVersionUID = 5640224091610000001L
     }
 
     var id: Long? = null

+ 1 - 1
zen-mq/src/main/kotlin/com/gxzc/zen/mq/consumer/Receiver.kt

@@ -1,4 +1,4 @@
-//package com.gxzc.zen.mq.consumer
+//package com.gxzc.zen.mq.api
 //
 //import org.slf4j.LoggerFactory
 //import org.springframework.amqp.rabbit.annotation.RabbitListener

+ 13 - 0
zen-rpc/src/main/kotlin/com/gxzc/zen/rpc/api/TestRpcService.kt

@@ -0,0 +1,13 @@
+//package com.gxzc.zen.rpc.api
+//
+///**
+// * 示例代码(接口)
+// * A/B 业务系统定义一个统一的接口,此接口需按照实际实现的业务系统进行划分
+// * A/B 业务系统间要定义一个统一的数据模型以便进行交互(不建议直接使用string)
+// * @author NorthLan
+// * @date 2018/5/7
+// * @url https://noahlan.com
+// */
+//interface TestRpcService {
+//    fun sayHello(name: String): String
+//}

+ 28 - 0
zen-rpc/src/main/kotlin/com/gxzc/zen/rpc/provider/TestRpcServiceImpl.kt

@@ -0,0 +1,28 @@
+//package com.gxzc.zen.rpc.provider
+//
+//import com.alibaba.dubbo.config.annotation.Service
+//import com.gxzc.zen.rpc.api.TestRpcService
+//
+///**
+// * 示例代码(接口实现,服务提供者或生产者)
+// * 服务提供者(生产者)实现接口供消费者使用
+// * 例:
+// * A/B 业务系统定义了接口TestRpcService且由B业务系统来实现 此时B为生产者 A为消费者
+// * 消费者无需关心接口如何实现(只需要定义接口然后调用即可)
+// * B:
+// *  Service实现类需加入注解@Service并指定版本号(默认1.0) [com.alibaba.dubbo.config.annotation.Service] 请注意包名
+// * A:
+// *  使用@Reference(version = "1.0", application = "\${dubbo.application.id}") 注入 [com.alibaba.dubbo.config.annotation.Reference] 请注意包名
+// *  注: java: @Reference(version = "1.0", application = "${dubbo.application.id}")
+// * @author NorthLan
+// * @date 2018/5/7
+// * @url https://noahlan.com
+// */
+//@Service(version = "1.0",
+//        application = "\${dubbo.application.id}")
+//class TestRpcServiceImpl : TestRpcService {
+//    override fun sayHello(name: String): String {
+//        println("say hello: $name")
+//        return name
+//    }
+//}

+ 1 - 0
zen-web/build.gradle

@@ -17,6 +17,7 @@ dependencies {
     compile project(":zen-api")
     compile project(":zen-mq")
     compile project(":zen-job")
+    compile project(":zen-rpc")
 }
 
 bootRepackage {

+ 1 - 0
zen-web/src/main/kotlin/com/gxzc/zen/MainApplication.kt

@@ -8,6 +8,7 @@ import org.springframework.boot.web.support.SpringBootServletInitializer
 
 
 @SpringBootApplication(exclude = [RedisAutoConfiguration::class])
+//@EnableDubboConfiguration
 //@ImportResource(locations = ["classpath:application-shiro.xml"])
 //@EnableRedisHttpSession
 class MainApplication : SpringBootServletInitializer() {

+ 5 - 0
zen-web/src/main/kotlin/com/gxzc/zen/web/sys/controller/TestController.kt

@@ -28,4 +28,9 @@ class TestController : BaseController() {
 
         }
     }
+
+    @GetMapping("/rpc")
+    fun rpc() {
+//        println(testRpcService.sayHello("2333"))
+    }
 }

+ 20 - 0
zen-web/src/main/resources/application-rpc.yml

@@ -0,0 +1,20 @@
+dubbo:
+  enabled: false
+  application:
+    name: zen-dubbo
+    id: zen-dubbo
+  scan:
+    base-packages: com.gxzc.zen.rpc.provider
+  protocol:
+    id: dubbo
+    name: dubbo
+    port: -1
+  registry:
+    address: 192.168.1.10:2181
+    protocol: zookeeper
+    client: curator
+    id: zen-reg
+  consumer:
+    check: false
+    lazy: true
+    timeout: 300000

+ 3 - 1
zen-web/src/main/resources/application.yml

@@ -10,7 +10,7 @@ zen:
 spring:
   profiles:
     active: dev
-    include: orm,mq,cache,umps,platform,job
+    include: orm,rpc,mq,cache,umps,platform,job
 #  redis:
 #    host: localhost
 #    port: 6379
@@ -30,6 +30,8 @@ spring:
       fail-on-unknown-properties: false # 多余字段反序列化过滤
   session:
     store-type: redis
+  application:
+    name: Zen
 
 logging:
   level: