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