This commit is contained in:
redkale
2023-12-24 21:08:57 +08:00
parent ae03bdecad
commit 88392fd5dd
6 changed files with 115 additions and 13 deletions

View File

@@ -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
*
* <p>
* 详情见: 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;
}

View File

@@ -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<String> queryTopic();
//ServiceLoader时判断配置是否符合当前实现类

View File

@@ -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())) {

View File

@@ -88,6 +88,8 @@ public interface Invoker<C, R> {
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<C, R> {
}
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) {