💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# 组件源码 ``` @InParams(param = { @Param(name = "future", comment = "future", type = Future.class), @Param(name = "timeoutInSecs", comment = "超时时间(秒)", type = int.class) }) @OutParams(param = { @Param(name = "data", comment = "数据", type = Object.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功") }) @Component(label = "从异步组件中获取数据", style = "判断型", type = "同步组件", comment = "当Future已经完成时立即返回结果, 否则同步阻塞直到超时或者Future完成。当超时时间小于等于0时,超时时间为Future的超时时间", version = "1.0.0", deprecated = false, date = "Fri Jul 17 15:28:00 CST 2018") public static ResultBase P_getDataFromFuture(Object future, int timeoutInSecs) { if (!(future instanceof Future)) { return ResultBase.newFailureResult("TPTK0004", "参数必须是future类型"); } else { try { Object data; if (timeoutInSecs <= 0) { timeoutInSecs = 60; } data = ((Future) future).get((long) timeoutInSecs, TimeUnit.SECONDS); return ResultBase.newSuccessResult(new Object[] { data }); } catch (ExecutionException arg3) { return ResultBase.newExceptionResult("TPTK0005", "线程执行异常:" + arg3); } catch (InterruptedException arg4) { return ResultBase.newExceptionResult("TPTK0006", "线程wait被中断:" + arg4); } catch (TimeoutException arg5) { return ResultBase.newExceptionResult("TPTK0007", "等待时间超时:" + arg5); } } } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/8d/f5/8df5447e1804658139e1cda132638cc9_1870x892.png) # 参数说明及示例 ## 入口参数 future:Future 类型的参数,示例: `__INNER__["future"]` 超时时间(秒):指定时间内完成,示例: `2` ## 出口参数 数据:从异步组件中获取数据,示例: `__INNER__["result"]` > 异步组件要自己写。