This commit is contained in:
@@ -534,13 +534,24 @@ public abstract class NodeServer {
|
|||||||
|
|
||||||
//Service.destroy执行之前调用
|
//Service.destroy执行之前调用
|
||||||
protected void preDestroyServices(Set<Service> localServices, Set<Service> remoteServices) {
|
protected void preDestroyServices(Set<Service> localServices, Set<Service> remoteServices) {
|
||||||
final ClusterAgent cluster = application.clusterAgent;
|
if (application.clusterAgent != null) { //服务注销
|
||||||
if (cluster == null) return;
|
final ClusterAgent agent = application.clusterAgent;
|
||||||
NodeProtocol pros = getClass().getAnnotation(NodeProtocol.class);
|
NodeProtocol pros = getClass().getAnnotation(NodeProtocol.class);
|
||||||
String protocol = pros.value().toUpperCase();
|
String protocol = pros.value().toUpperCase();
|
||||||
if (!cluster.containsProtocol(protocol)) return;
|
if (agent.containsProtocol(protocol) && agent.containsPort(server.getSocketAddress().getPort())) {
|
||||||
if (!cluster.containsPort(server.getSocketAddress().getPort())) return;
|
agent.deregister(this, protocol, localServices, remoteServices);
|
||||||
cluster.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();
|
protected abstract ClassFilter<Filter> createFilterClassFilter();
|
||||||
@@ -678,6 +689,7 @@ public abstract class NodeServer {
|
|||||||
public void start() throws IOException {
|
public void start() throws IOException {
|
||||||
if (interceptor != null) interceptor.preStart(this);
|
if (interceptor != null) interceptor.preStart(this);
|
||||||
server.start();
|
server.start();
|
||||||
|
postStartServer(localServices, remoteServices);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() throws IOException {
|
public void shutdown() throws IOException {
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ import java.io.Serializable;
|
|||||||
import org.redkale.convert.json.JsonConvert;
|
import org.redkale.convert.json.JsonConvert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* 详情见: https://redkale.org
|
||||||
*
|
*
|
||||||
* @author zhangjx
|
* @author zhangjx
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ import java.nio.ByteBuffer;
|
|||||||
import org.redkale.net.http.*;
|
import org.redkale.net.http.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* 详情见: https://redkale.org
|
||||||
*
|
*
|
||||||
* @author zhangjx
|
* @author zhangjx
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ import org.redkale.net.http.*;
|
|||||||
import org.redkale.util.ObjectPool;
|
import org.redkale.util.ObjectPool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* 详情见: https://redkale.org
|
||||||
*
|
*
|
||||||
* @author zhangjx
|
* @author zhangjx
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ package org.redkale.mq;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Logger;
|
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.service.Service;
|
||||||
import org.redkale.util.AnyValue;
|
import org.redkale.util.AnyValue;
|
||||||
|
|
||||||
@@ -62,4 +65,31 @@ public abstract class MessageAgent {
|
|||||||
|
|
||||||
//查询所有topic
|
//查询所有topic
|
||||||
public abstract List<String> queryTopic();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
package org.redkale.mq;
|
package org.redkale.mq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* 详情见: https://redkale.org
|
||||||
*
|
*
|
||||||
* @author zhangjx
|
* @author zhangjx
|
||||||
*/
|
*/
|
||||||
|
|||||||
17
src/org/redkale/mq/MessageStreams.java
Normal file
17
src/org/redkale/mq/MessageStreams.java
Normal 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 {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -172,7 +172,7 @@ public final class Rest {
|
|||||||
return (!controller.name().isEmpty()) ? controller.name().trim() : serviceType.getSimpleName().replaceAll("Service.*$", "").toLowerCase();
|
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);
|
final RestService controller = serviceType.getAnnotation(RestService.class);
|
||||||
if (controller == null) return serviceType.getSimpleName().replaceAll("Service.*$", "");
|
if (controller == null) return serviceType.getSimpleName().replaceAll("Service.*$", "");
|
||||||
if (controller.ignore()) return null;
|
if (controller.ignore()) return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user