调用webservice,3秒调不通就直接返回
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();
}
阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012031022/article/details/51556542
文章标签: web service
个人分类: JAVA
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

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

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭