我正在尝试运行poll,poll1,poll2方法以独立运行,现在,如果poll()正在运行并且处理时间超过10秒,其他方法正在等待poll()完成其处理。我在poll()sys out处保留了一个断点,而sys out的其他方法未执行。 如何解决呢?下面是代码库。
我也尝试添加
@ConcurrencyManagement(ConcurrencyManagementType.CONTAINER)
@Lock(LockType.READ)
但没有发现行为上的改变。
@Singleton
public class SchedulerA {
@Schedule(second = "*/10", minute = "*", hour = "*", persistent = false)
public void poll() {
System.out.println("SchedulerA:: poll()");
}
@Schedule(second = "*/10", minute = "*", hour = "*", persistent = false)
public void poll1() {
System.out.println("SchedulerA:: poll()1");
}
@Schedule(second = "*/10", minute = "*", hour = "*", persistent = false)
public void poll2() {
System.out.println("SchedulerA:: poll()2");
}
}
我期望poll()是否正在运行(输入一个断点/或添加一个for循环,这需要10秒钟以上)输出show SchedulerA :: poll()1 SchedulerA :: poll()2 再过10秒 SchedulerA :: poll()1 SchedulerA :: poll()2
答案 0 :(得分:0)
也许一些解决方法是使用ManagedScheduledExecutorService。 像这样注入来使用它:
%*Creates a list of all files in the DIR directory with the specified extension (EXT);
%macro list_files(dir,ext);
%local filrf rc did memcnt name i;
%let rc=%sysfunc(filename(filrf,&dir));
%let did=%sysfunc(dopen(&filrf));
%if &did eq 0 %then
%do;
%put Directory &dir cannot be open or does not exist;
%return;
%end;
%do i = 1 %to %sysfunc(dnum(&did));
%let name=%qsysfunc(dread(&did,&i));
%if %qupcase(%qscan(&name,-1,.)) = %upcase(&ext) %then
%do;
%put &dir\&name;
%let file_name = %qscan(&name,1,.);
%put &file_name;
data _tmp;
length dir $512 name $100;
dir=symget("dir");
name=symget("name");
path = catx('\',dir,name);
the_name = substr(name,1,find(name,'.')-1);
run;
proc append base=list data=_tmp force;
run;
quit;
proc sql;
drop table _tmp;
quit;
%end;
%else %if %qscan(&name,2,.) = %then
%do;
%list_files(&dir\&name,&ext)
%end;
%end;
%let rc=%sysfunc(dclose(&did));
%let rc=%sysfunc(filename(filrf));
%mend list_files;
%*Macro to import a single file, using the path, filename and an output dataset name must be specified;
%macro import_file(path, file_name, dataset_name );
proc import
datafile="&path.\&file_name."
dbms=csv
out=&dataset_name replace;
run;
%mend;
*Create the list of files, in this case all CSV files;
%list_files(C:\Users\baidw002\Documents\1 BCH-LJAF\Real data transfer (BCH to UAB)\CGM\cgmtestfiles\machine\csv, csv);
%*Call macro once for each entry in the list table created from the %list_files() macro;
data _null_;
set list;
string = catt('%import_file(', dir, ', ', name,', ', catt('test', put(_n_, z2.)), ');');
call execute (string);
run;
并安排@PostConstruct中的上述任务以固定的延迟执行,例如
@Resource
private ManagedScheduledExecutorService scheduledExecutorService;
等