diff --git a/docs/service.md b/docs/service.md
index 46636aeda..db0363990 100644
--- a/docs/service.md
+++ b/docs/service.md
@@ -1,8 +1,8 @@
# Service组件
- Service是Redkale最核心的组件,主要处理业务逻辑和操作数据层。Service实例分两种模式: 本地模式和远程模式。其模式由```conf/application.xml```文件来配置。开发人员在调用过程中通常不需要区分Service实例是哪种模式。
- 并不是Sevice都能进行本地和远程模式切换, 以下情况的Service不能转成远程模式:
- * Service类修饰为```final```
- * Service类被标记```@Local```
- * Service类被标记```@Component```
+>Service是Redkale最核心的组件,主要处理业务逻辑和操作数据层。Service实例分两种模式: 本地模式和远程模式。其模式由```conf/application.xml```文件来配置。开发人员在调用过程中通常不需要区分Service实例是哪种模式。
+>并不是Sevice都能进行本地和远程模式切换, 以下情况的Service不能转成远程模式:
+ 1、Service类修饰为```final```
+ 2、Service类被标记```@Local```
+ 3、Service类被标记```@Component```
Redkale进程启动时扫描可加载的Service实现类,根据配置文件配置的模式采用```ASM```技术动态生成相应的Service临时类进行实例化,并注册到ResourceFactory同其他Service、Servlet依赖注入。
\ No newline at end of file
diff --git a/src/main/java/org/redkale/mq/Messaged.java b/src/main/java/org/redkale/mq/Messaged.java
new file mode 100644
index 000000000..a23b9367e
--- /dev/null
+++ b/src/main/java/org/redkale/mq/Messaged.java
@@ -0,0 +1,37 @@
+/*
+ *
+ */
+package org.redkale.mq;
+
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import org.redkale.convert.ConvertType;
+
+/**
+ * MQ资源注解, 只能标记在Service类方法上
+ * 1、方法必须是protected/public
+ * 2、方法不能是final
+ *
+ *
+ * 详情见: https://redkale.org
+ *
+ * @author zhangjx
+ *
+ * @since 2.8.0
+ */
+@Documented
+@Target({METHOD})
+@Retention(RUNTIME)
+public @interface Messaged {
+
+ String mq() default "";
+
+ String group() default "";
+
+ String[] topics();
+
+ ConvertType convertType() default ConvertType.JSON;
+}
diff --git a/src/main/java/org/redkale/mq/spi/MessageAgent.java b/src/main/java/org/redkale/mq/spi/MessageAgent.java
index 49ccb5d89..474da011c 100644
--- a/src/main/java/org/redkale/mq/spi/MessageAgent.java
+++ b/src/main/java/org/redkale/mq/spi/MessageAgent.java
@@ -218,7 +218,7 @@ public abstract class MessageAgent implements MessageManager {
if (this.timeoutExecutor != null) {
this.timeoutExecutor.shutdownNow();
}
- if (this.workExecutor != null && this.workExecutor != application.getWorkExecutor()) {
+ if (this.workExecutor != application.getWorkExecutor()) {
this.workExecutor.shutdown();
}
}
@@ -400,12 +400,15 @@ public abstract class MessageAgent implements MessageManager {
public abstract void onResourceChange(ResourceEvent[] events);
//
+ @Override
public abstract boolean createTopic(String... topics);
//删除topic,如果不存在则跳过
+ @Override
public abstract boolean deleteTopic(String... topics);
//查询所有topic
+ @Override
public abstract List queryTopic();
//ServiceLoader时判断配置是否符合当前实现类
diff --git a/src/main/java/org/redkale/net/sncp/Sncp.java b/src/main/java/org/redkale/net/sncp/Sncp.java
index 8047399de..ae9091074 100644
--- a/src/main/java/org/redkale/net/sncp/Sncp.java
+++ b/src/main/java/org/redkale/net/sncp/Sncp.java
@@ -85,11 +85,6 @@ public abstract class Sncp {
continue;
}
if (method.getAnnotation(Scheduled.class) != null) {
- if (Modifier.isStatic(method.getModifiers())
- || method.getParameterCount() > 0) {
- throw new SncpException(Scheduled.class.getSimpleName() + " must be on protected and non-parameter method, but on " + method);
- }
- RedkaleClassLoader.putReflectionMethod(serviceTypeOrImplClass.getName(), method);
continue;
}
if (Modifier.isStatic(method.getModifiers())) {
diff --git a/src/main/java/org/redkale/util/Invoker.java b/src/main/java/org/redkale/util/Invoker.java
index 4c338ac07..e1e2d99b0 100644
--- a/src/main/java/org/redkale/util/Invoker.java
+++ b/src/main/java/org/redkale/util/Invoker.java
@@ -88,6 +88,8 @@ public interface Invoker {
returnDesc = Type.getDescriptor(Long.class);
} else if (returnType == double.class) {
returnDesc = Type.getDescriptor(Double.class);
+ } else if (returnType == void.class) {
+ returnDesc = Type.getDescriptor(Void.class);
}
ClassLoader loader = Thread.currentThread().getContextClassLoader();
StringBuilder sbpts = new StringBuilder();
@@ -144,7 +146,11 @@ public interface Invoker {
}
mv.visitMethodInsn(staticFlag ? INVOKESTATIC : (clazz.isInterface() ? INVOKEINTERFACE : INVOKEVIRTUAL), interName, method.getName(), "(" + paramDescs + ")" + returnPrimiveDesc, !staticFlag && clazz.isInterface());
- Asms.visitPrimitiveValueOf(mv, returnType);
+ if (returnType == void.class) {
+ mv.visitInsn(ACONST_NULL);
+ } else {
+ Asms.visitPrimitiveValueOf(mv, returnType);
+ }
mv.visitLabel(label1);
mv.visitInsn(ARETURN);
if (throwFlag) {
diff --git a/src/test/java/org/redkale/test/util/InvokerTest.java b/src/test/java/org/redkale/test/util/InvokerTest.java
index 6716ed67d..1447e5fa8 100644
--- a/src/test/java/org/redkale/test/util/InvokerTest.java
+++ b/src/test/java/org/redkale/test/util/InvokerTest.java
@@ -5,9 +5,10 @@
*/
package org.redkale.test.util;
-import org.redkale.util.Invoker;
+import java.io.IOException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+import org.redkale.util.Invoker;
/**
*
@@ -15,6 +16,17 @@ import org.junit.jupiter.api.Test;
*/
public class InvokerTest {
+ public static void main(String[] args) throws Throwable {
+ InvokerTest test = new InvokerTest();
+ test.run1();
+ test.run2();
+ test.run3();
+ test.run4();
+ test.run5();
+ test.run6();
+ test.run7();
+ }
+
@Test
public void run1() {
Invoker invoker = Invoker.create(String.class, "toLowerCase");
@@ -34,4 +46,53 @@ public class InvokerTest {
System.out.println(str);
Assertions.assertEquals(str, invoker.invoke(null, str).toString());
}
+
+ @Test
+ public void run4() {
+ Invoker invoker = Invoker.create(Action.class, "test1");
+ Action action = new Action();
+ invoker.invoke(action);
+ }
+
+ @Test
+ public void run5() {
+ Invoker invoker = Invoker.create(Action.class, "test2", String.class);
+ Action action = new Action();
+ invoker.invoke(action, "name");
+ }
+
+ @Test
+ public void run6() {
+ Invoker invoker = Invoker.create(Action.class, "test3", String.class, int.class);
+ Action action = new Action();
+ int rs = invoker.invoke(action, "name", 1);
+ System.out.println(rs);
+ Assertions.assertEquals(3, rs);
+ }
+
+ @Test
+ public void run7() {
+ Invoker invoker = Invoker.create(Action.class, "test4", String.class, int.class);
+ Action action = new Action();
+ int rs = invoker.invoke(action, "name", 1);
+ System.out.println(rs);
+ Assertions.assertEquals(4, rs);
+ }
+
+ public static class Action {
+
+ public void test1() {
+ }
+
+ public void test2(String name) throws IOException {
+ }
+
+ public int test3(String name, int id) {
+ return 3;
+ }
+
+ public int test4(String name, int id) throws IOException {
+ return 4;
+ }
+ }
}