• xxl-job编写GULE(Java)运行模式,带执行参数(url)


    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/#/

  • 相关阅读:
    day1 生活大爆炸版石头剪刀布
    友谊赛
    再数17
    素数统计
    day1 LGTB玩THD
    day1 LGTB学分块
    day1 LGTB玩扫雷
    组合(1-m中选n个数)
    二分查找法,加递归,之前做了一个没加递归,结果就废了
    以前的一个程序,死循环,骚年,卡爆你的电脑吧
  • 原文地址:https://www.cnblogs.com/ouyanxia/p/9122368.html
Copyright © 2020-2023  润新知