可以试试使用反射或者传递函数的方式
try{
Map params=(Map)var2;
Class c=(Class) params.get("class");
Class[] argsClass=(Class[])params.get("argsClass");
Object[] args=(Object[])params.get("args");
String methodName=params.get("methodName").toString();
Method method=c.getMethod(methodName,argsClass);
method.invoke(c.newInstance(),args);
return RocketMQLocalTransactionState.COMMIT;
}catch (Exception e){
return RocketMQLocalTransactionState.ROLLBACK;
}
try{
LocalListenerFunction function=(LocalListenerFunction)var2;
function.execute();
return RocketMQLocalTransactionState.COMMIT;
}catch (Exception e){
return RocketMQLocalTransactionState.ROLLBACK;
}
https://blog.csdn.net/qq_41066277/article/details/122070210?spm=1001.2014.3001.5501