This commit is contained in:
Redkale
2020-05-29 16:06:02 +08:00
parent 4c4913c5d0
commit ed1fb151d7
8 changed files with 83 additions and 8 deletions

View File

@@ -534,13 +534,24 @@ public abstract class NodeServer {
//Service.destroy执行之前调用
protected void preDestroyServices(Set<Service> localServices, Set<Service> remoteServices) {
final ClusterAgent cluster = application.clusterAgent;
if (cluster == null) return;
NodeProtocol pros = getClass().getAnnotation(NodeProtocol.class);
String protocol = pros.value().toUpperCase();
if (!cluster.containsProtocol(protocol)) return;
if (!cluster.containsPort(server.getSocketAddress().getPort())) return;
cluster.deregister(this, protocol, localServices, remoteServices);
if (application.clusterAgent != null) { //服务注销
final ClusterAgent agent = application.clusterAgent;
NodeProtocol pros = getClass().getAnnotation(NodeProtocol.class);
String protocol = pros.value().toUpperCase();
if (agent.containsProtocol(protocol) && agent.containsPort(server.getSocketAddress().getPort())) {
agent.deregister(this, protocol, localServices, remoteServices);
}
}
if (application.messageAgent != null) { //MQ
}
}
//Server.start执行之后调用
protected void postStartServer(Set<Service> localServices, Set<Service> remoteServices) {
if (application.messageAgent != null) { //MQ
final MessageAgent agent = application.messageAgent;
}
}
protected abstract ClassFilter<Filter> createFilterClassFilter();
@@ -678,6 +689,7 @@ public abstract class NodeServer {
public void start() throws IOException {
if (interceptor != null) interceptor.preStart(this);
server.start();
postStartServer(localServices, remoteServices);
}
public void shutdown() throws IOException {

View File

@@ -9,6 +9,10 @@ import java.io.Serializable;
import org.redkale.convert.json.JsonConvert;
/**
*
*
* <p>
* 详情见: https://redkale.org
*
* @author zhangjx
*/

View File

@@ -9,6 +9,10 @@ import java.nio.ByteBuffer;
import org.redkale.net.http.*;
/**
*
*
* <p>
* 详情见: https://redkale.org
*
* @author zhangjx
*/

View File

@@ -13,6 +13,10 @@ import org.redkale.net.http.*;
import org.redkale.util.ObjectPool;
/**
*
*
* <p>
* 详情见: https://redkale.org
*
* @author zhangjx
*/

View File

@@ -7,6 +7,9 @@ package org.redkale.mq;
import java.util.*;
import java.util.logging.Logger;
import org.redkale.boot.*;
import org.redkale.net.http.Rest;
import org.redkale.net.sncp.Sncp;
import org.redkale.service.Service;
import org.redkale.util.AnyValue;
@@ -62,4 +65,31 @@ public abstract class MessageAgent {
//查询所有topic
public abstract List<String> queryTopic();
//格式: sncp:req:user
protected static String generateSncpReqTopic(NodeServer ns, Service service) {
String resname = Sncp.getResourceName(service);
return "sncp:req:" + Sncp.getResourceType(service).getSimpleName().replaceAll("Service.*$", "").toLowerCase() + (resname.isEmpty() ? "" : ("-" + resname));
}
//格式: sncp:resp:node10
protected static String generateSncpRespTopic(Application application) {
return "sncp:resp:node" + application.getNodeid();
}
//格式: http:req:user
protected static String generateHttpReqTopic(NodeServer ns, Service service) {
String resname = Sncp.getResourceName(service);
return "http:req:" + Rest.getWebModuleName(service.getClass()).toLowerCase() + (resname.isEmpty() ? "" : ("-" + resname));
}
//格式: http:resp:node10
protected static String generateHttpRespTopic(Application application) {
return "http:resp:node" + application.getNodeid();
}
//格式: ws:resp:node10
protected static String generateWebSocketRespTopic(Application application) {
return "ws:resp:node" + application.getNodeid();
}
}

View File

@@ -6,6 +6,10 @@
package org.redkale.mq;
/**
*
*
* <p>
* 详情见: https://redkale.org
*
* @author zhangjx
*/

View File

@@ -0,0 +1,17 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.redkale.mq;
/**
*
* <p>
* 详情见: https://redkale.org
*
* @author zhangjx
*/
public interface MessageStreams {
}

View File

@@ -172,7 +172,7 @@ public final class Rest {
return (!controller.name().isEmpty()) ? controller.name().trim() : serviceType.getSimpleName().replaceAll("Service.*$", "").toLowerCase();
}
static String getWebModuleName(Class<? extends Service> serviceType) {
public static String getWebModuleName(Class<? extends Service> serviceType) {
final RestService controller = serviceType.getAnnotation(RestService.class);
if (controller == null) return serviceType.getSimpleName().replaceAll("Service.*$", "");
if (controller.ignore()) return null;