d9f4ab7db1fd672e0f2fc14564b3278f556191d5
\345\275\223\345\211\215SDK\347\211\210\346\234\254\344\270\215\346\224\257\346\214\201\350\277\234\347\250\213\350\260\203\347\224\250\357\274\214\350\257\267\345\215\207\347\272\247SDK\345\206\215\345\260\235\350\257\225\357\274\201.md
| ... | ... | @@ -1,102 +1,2 @@ |
| 1 | 1 | # 当前SDK版本不支持远程调用,请升级SDK再尝试! |
| 2 | 2 | |
| 3 | -``` |
|
| 4 | -2024-07-25 10:51:14.911[alarm-1-thread-2]ERROR mesLog -企业微信推送失败:当前上下文token内容为空,不支持远程调用! |
|
| 5 | -com.sie.snest.engine.exception.ModelException:当前上下文token内容为空,不支持远程调用! |
|
| 6 | -at com.sie.snest.engine.model.MethodMeta.invoke(MethodMeta.java:190) |
|
| 7 | -at com.sie.snest.engine.api.distributed.RpcInvocation.invoke(RpcInvocation.java:184) |
|
| 8 | -at com.sie.snest.engine.data.Recordset.call(Recordset.java:295) |
|
| 9 | -at com.sie.pip.mes.alarm.service.AlarmwebSocketclientHandlerService.sendMes(AlarmwebSocketclientHandlerService.java:1219) |
|
| 10 | -at com.sie.pip.mes.alarm.service.AlarmwebSocketclientHandlerService.lambda$getUserPushProcessings$16(AlarmwebSocketclientHandlerService.java:1106) |
|
| 11 | -at com.sie.pip.mes.common.utils.ThreadPoolUtil.lambda$executeSo$0(ThreadPoolUtil.java:50) |
|
| 12 | -at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) |
|
| 13 | -at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) |
|
| 14 | -at java.lang.Thread.run(Thread.java:748) |
|
| 15 | -Caused by:com.sie.snest.engine.exception.CallException:当前上下文token内容为空,不支持远程调用! |
|
| 16 | -at com.sie.snest.engine.api.distributed.RpcInvocation.getToken(RpcInvocation.java:64) |
|
| 17 | -at com.sie.snest.engine.api.distributed.RpcInvocation.getHeaderAndBody(RpcInvocation.java:51) |
|
| 18 | -at com.sie.snest.engine.api.distributed.RpcInvocation.invoke(RpcInvocation.java:125) |
|
| 19 | -at com.sie.snest.engine.data.Recordset.call(Recordset.java:295) |
|
| 20 | -at com.sie.snest.engine.data.Recordset.search(Recordset.java:185) |
|
| 21 | -at com.sie.pip.mes.qywx.service.MobileSenderService.obtainChannelInfo(MobileSenderService.java:217) |
|
| 22 | -at com.sie.pip.mes.qywx.service.MobileSenderService.sender(MobileSenderService.java:65) |
|
| 23 | -at com.sie.pip.mes.qywx.service.MobileSenderService$$EnhancerByCGLIB$$93162c76.CGLIB$sender$0(<generated>) |
|
| 24 | -at com.sie.pip.mes.qywx.service.MobileSenderService$$EnhancerByCGLIB$$93162c76$$FastClassByCGLIB$$93a581f.invoke(<generated>) |
|
| 25 | -at net.sf.cglib.proxy.MethodProxy.invokesuper(MethodProxy.java:228) |
|
| 26 | -at com.sie.snest.engine.model.ModelInterceptor.intercept(ModelInterceptor.java:84) |
|
| 27 | -at com.sie.pip.mes.qywx.service.MobileSenderService$$EnhancerByCGLIB$$93162c76.sender(<generated>) |
|
| 28 | -at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) |
|
| 29 | -at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) |
|
| 30 | -at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) |
|
| 31 | -at java.lang.reflect.Method.invoke(Method.java:498) |
|
| 32 | -at com.sie.snest.engine.model.MethodMeta.execute(MethodMeta.java:226) |
|
| 33 | -at com.sie.snest.engine.model.MethodMeta.invoke(MethodMeta.java:179) |
|
| 34 | -``` |
|
| 35 | - |
|
| 36 | -## 解决方案 |
|
| 37 | - |
|
| 38 | - |
|
| 39 | - |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - |
|
| 43 | -检查如下示例代码: |
|
| 44 | -``` |
|
| 45 | - try (Meta meta1 = new Meta(null, new HashMap<>())){ |
|
| 46 | - |
|
| 47 | - |
|
| 48 | -} |
|
| 49 | -``` |
|
| 50 | - |
|
| 51 | -new HashMap() 需要调整如下所示: |
|
| 52 | - |
|
| 53 | -``` |
|
| 54 | -try (Meta meta1 = new Meta(null, BaseContextHandler.getMeta().getContext())){ |
|
| 55 | - |
|
| 56 | -} |
|
| 57 | - |
|
| 58 | -``` |
|
| 59 | - |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - |
|
| 63 | - |
|
| 64 | -## 为什么需要自己new Meta() |
|
| 65 | - |
|
| 66 | -场景1 : 服务是异步的情况,不是通过页面的API接口,以及启动事件触发! |
|
| 67 | - |
|
| 68 | -平台提供了执行异步服务 |
|
| 69 | - |
|
| 70 | -示例代码如下所示: |
|
| 71 | - |
|
| 72 | -``` |
|
| 73 | - @MethodService(description = "发送消息") |
|
| 74 | - public void sendMsg(RecordSet rs){ |
|
| 75 | - rs.callAsync("openWebSocket", 9999 ); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - @MethodService(description = "打开websocket端口") |
|
| 79 | - public void openWebSocket(int port){ |
|
| 80 | - |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | -``` |
|
| 84 | - |
|
| 85 | - |
|
| 86 | - |
|
| 87 | -场景2: 消费事件执行服务的情况! |
|
| 88 | - |
|
| 89 | -异步服务并不是通过引擎触发,提供如下代码所示: |
|
| 90 | - |
|
| 91 | -BaseContextHandler.getMeta().getContext() 需要把同步的数据传递给新创建的Meta类。 |
|
| 92 | -如果实在没有,可以通过查库获取token内容。 |
|
| 93 | - |
|
| 94 | - |
|
| 95 | -``` |
|
| 96 | - |
|
| 97 | - |
|
| 98 | -try (Meta meta1 = new Meta(null, BaseContextHandler.getMeta().getContext())){ |
|
| 99 | - |
|
| 100 | -} |
|
| 101 | - |
|
| 102 | -``` |