package com.xxl.job.service.handler;

import com.xxl.job.core.log.XxlJobLogger;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;

public class queryAllinpayWxH5ResultGlueJobHandler extends IJobHandler {

    @Override
    public ReturnT<String> execute(String... arg0) throws Exception {
             String result = null; 
                InputStream input = null;  
            String uri ="";
            try {  
                uri = arg0[0];//传进来的参数
                URL url = new URL(uri);  
                HttpURLConnection urlcon = (HttpURLConnection) url.openConnection();  
                urlcon.setRequestMethod("POST");  
                urlcon.connect();// 获取连接  
                input = urlcon.getInputStream();  
                BufferedReader buffer = new BufferedReader(new InputStreamReader(  
                        input, "UTF-8"));  
                StringBuffer bs = new StringBuffer();  
                String line = null;  
                while ((line = buffer.readLine()) != null) {  
                    bs.append(line);  
                }  
                result = bs.toString();  
                XxlJobLogger.log("result:"+result);
            } catch (Exception e) {  
              XxlJobLogger.log("[请求异常][地址:" + uri + "][错误信息:" + e.getMessage()  
                        + "]");
                return ReturnT.FAIL;
            } finally {  
                try {  
                    if (null != input)  
                        input.close();  
                } catch (Exception e2) {  
                   XxlJobLogger.log("[关闭流异常][错误信息:" + e2.getMessage() + "]");  
                }  
            }  
            return ReturnT.SUCCESS;  
    }
}

 配置任务信息:

执行参数:需要传递的参数

 

 xxl-job官方文档地址:http://www.xuxueli.com/xxl-job/#/

转载于:https://www.cnblogs.com/ouyanxia/p/9122368.html

GitHub 加速计划 / xx / xxl-job
27.15 K
10.79 K
下载
xxl-job: 是一个分布式任务调度平台,核心设计目标是开发迅速、学习简单、轻量级、易扩展。
最近提交(Master分支:3 个月前 )
e5d26ba2 - 3 个月前
977ad87b - 3 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐