This repository has been archived by the owner on Jul 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/4.0' into 4.0
- Loading branch information
Showing
88 changed files
with
2,561 additions
and
1,005 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
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
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 |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
<description>EZ框架Parent Component POM</description> | ||
<url>https://github.com/gudaoxuri/ez-framework</url> | ||
<packaging>pom</packaging> | ||
<version>4.0-SNAPSHOT</version> | ||
<version>4.0.1-SNAPSHOT</version> | ||
|
||
<scm> | ||
<connection>scm:git:[email protected]:gudaoxuri/ez-framework.git</connection> | ||
|
@@ -24,7 +24,7 @@ | |
</scm> | ||
|
||
<properties> | ||
<ezf-version>4.0-SNAPSHOT</ezf-version> | ||
<ezf-version>4.0.1-SNAPSHOT</ezf-version> | ||
</properties> | ||
|
||
<modules> | ||
|
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
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 |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
<description>EZ框架Parent POM</description> | ||
<url>https://github.com/gudaoxuri/ez-framework</url> | ||
<packaging>pom</packaging> | ||
<version>4.0-SNAPSHOT</version> | ||
<version>4.0.1-SNAPSHOT</version> | ||
|
||
<scm> | ||
<connection>scm:git:[email protected]:gudaoxuri/ez-framework.git</connection> | ||
|
@@ -24,12 +24,15 @@ | |
</scm> | ||
|
||
<properties> | ||
<ezf-version>4.0-SNAPSHOT</ezf-version> | ||
<ezf-version>4.0.1-SNAPSHOT</ezf-version> | ||
<ez-common.version>1.2.3</ez-common.version> | ||
</properties> | ||
|
||
<modules> | ||
<module>services/core</module> | ||
<module>services/cluster-nats</module> | ||
<module>services/cluster-redis</module> | ||
<module>services/cluster-rabbitmq</module> | ||
<module>services/gateway</module> | ||
<module>services/jdbc</module> | ||
<module>services/email</module> | ||
|
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
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
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,42 @@ | ||
<?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> | ||
<groupId>com.ecfront</groupId> | ||
<artifactId>ezf-parent</artifactId> | ||
<version>4.0.1-SNAPSHOT</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>ezf-cluster-nats</artifactId> | ||
<name>EZ Framework cluster-nats</name> | ||
<description>EZ框架nats集群模块</description> | ||
<packaging>jar</packaging> | ||
<version>${ezf-version}</version> | ||
|
||
<properties> | ||
<jnats.version>0.7.3</jnats.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.ecfront</groupId> | ||
<artifactId>ezf-core</artifactId> | ||
<version>${ezf-version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.ecfront</groupId> | ||
<artifactId>ezf-test</artifactId> | ||
<version>${ezf-version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.nats</groupId> | ||
<artifactId>jnats</artifactId> | ||
<version>${jnats.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
23 changes: 23 additions & 0 deletions
23
services/cluster-nats/src/main/scala/com/ecfront/ez/framework/cluster/nats/NatsCluster.scala
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,23 @@ | ||
package com.ecfront.ez.framework.cluster.nats | ||
|
||
import com.ecfront.ez.framework.core.cluster._ | ||
|
||
import scala.beans.BeanProperty | ||
|
||
object NatsCluster extends Cluster { | ||
|
||
override val rpc: ClusterRPC = NatsClusterRPC | ||
|
||
override val mq: ClusterMQ = NatsClusterMQ | ||
|
||
override val dist: ClusterDist = null | ||
|
||
override val cache: ClusterCache = null | ||
|
||
override val manage: ClusterManage = NatsClusterManage | ||
} | ||
|
||
class MessageWrap { | ||
@BeanProperty var message: String = _ | ||
@BeanProperty var args: Map[String, String] = _ | ||
} |
51 changes: 51 additions & 0 deletions
51
...ces/cluster-nats/src/main/scala/com/ecfront/ez/framework/cluster/nats/NatsClusterMQ.scala
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,51 @@ | ||
package com.ecfront.ez.framework.cluster.nats | ||
|
||
import com.ecfront.common.JsonHelper | ||
import com.ecfront.ez.framework.core.EZ | ||
import com.ecfront.ez.framework.core.cluster.ClusterMQ | ||
import io.nats.client.{Message, MessageHandler} | ||
|
||
object NatsClusterMQ extends ClusterMQ { | ||
|
||
override def publish(topic: String, message: String, args: Map[String, String]): Unit = { | ||
val msgWrap = new MessageWrap | ||
msgWrap.message = message | ||
msgWrap.args = args | ||
NatsClusterManage.getConnection.publish(topic, JsonHelper.toJsonString(msgWrap).getBytes("UTF-8")) | ||
} | ||
|
||
override def subscribe(topic: String)(receivedFun: (String, Map[String, String]) => Unit): Unit = { | ||
NatsClusterManage.getConnection.subscribe(topic, new MessageHandler { | ||
override def onMessage(msg: Message) = { | ||
EZ.execute.execute(new Runnable { | ||
override def run(): Unit = { | ||
val replyMsg = JsonHelper.toObject[MessageWrap](new String(msg.getData, "UTF-8")) | ||
receivedFun(replyMsg.message, replyMsg.args) | ||
} | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
override def request(address: String, message: String, args: Map[String, String]): Unit = { | ||
val msgWrap = new MessageWrap | ||
msgWrap.message = message | ||
msgWrap.args = args | ||
NatsClusterManage.getConnection.request(address, JsonHelper.toJsonString(msgWrap).getBytes("UTF-8")) | ||
} | ||
|
||
override def response(address: String)(receivedFun: (String, Map[String, String]) => Unit): Unit = { | ||
NatsClusterManage.getConnection.subscribe(address, address, new MessageHandler { | ||
override def onMessage(msg: Message) = { | ||
EZ.execute.execute(new Runnable { | ||
override def run(): Unit = { | ||
val replyMsg = JsonHelper.toObject[MessageWrap](new String(msg.getData, "UTF-8")) | ||
receivedFun(replyMsg.message, replyMsg.args) | ||
NatsClusterManage.getConnection.publish(msg.getReplyTo, "".getBytes("UTF-8")) | ||
} | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
} |
Oops, something went wrong.