'How to execute flink sql tasks regularly every day?

Now, I use java TimerTask to implement it. The problem is that the flink environment is in TimerTask, which causes the submitted job to fail to recognize the job and report an error.

flink submit error screenshot

You can see that the flink environment is running in TimerTask

code show :

public class DimJob {
private static StreamExecutionEnvironment env;
 private  static EnvironmentSettings build;
 private static StreamTableEnvironment tenv;

public static void main(String[] args)throws Exception {

    TimerTask timerTask = new TimerTask() {
        @Override
        public void run() {

             env = StreamExecutionEnvironment.getExecutionEnvironment();

            env.setParallelism(1);

             build = EnvironmentSettings.newInstance()
                    .inStreamingMode()
                    .useBlinkPlanner()
                    .build();
             tenv = StreamTableEnvironment.create(env, build);



        }
    };

    Calendar calendar = Calendar.getInstance();
    int year = calendar.get(Calendar.YEAR);
    int month = calendar.get(Calendar.MONTH);
    int day = calendar.get(Calendar.DAY_OF_MONTH);
    long daySpan = 24 * 60 * 60 * 1000;
    calendar.set(year, month, day, 3, 00, 00);
    Date time = calendar.getTime();
    long time1 = time.getTime();



    System.out.println(time);

    Timer timer = new Timer();
    timer.schedule(timerTask,time,24*60*60*1000);



}

}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source