关闭

调用webservice,3秒调不通就直接返回

标签: web service
253人阅读 评论(0) 收藏 举报
分类:
private static ISysNotifyTodoWebService port1;
private Long second = 3l;


class ConnectService implements Callable<Boolean>{
    @Override
    public Boolean call() throws Exception {
         ISysNotifyTodoWebServiceService service = new ISysNotifyTodoWebServiceService();
         port1 = service.getISysNotifyTodoWebServicePort();
         return Boolean.TRUE;  
    }
}



public void persionTodoDone(String userId){
    ExecutorService es = Executors.newCachedThreadPool();
    ConnectService service = new ConnectService();

    try {
        //开始调用call
        Future<Boolean> future = es.submit(service);
        //设置时间:毫秒
        Boolean rtn = (Boolean) future.get(1000 * second, TimeUnit.MILLISECONDS);
        System.out.println("---------success---------"+rtn);

        if (null != port1) {
            dealMessage(userId);
        }
    } catch (InterruptedException e) {
        System.out.println("---------中断-------");
    } catch (ExecutionException e) {
        System.out.println("---------挂了-------");
    } catch (TimeoutException e) {
        System.out.println("---------超时-------");
        es.shutdownNow();
    }

    es.shutdown();
}
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:407次
    • 积分:34
    • 等级:
    • 排名:千里之外
    • 原创:3篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档