私は再生フレームワークを使い始めています。私は特定の数のws呼び出しを行うジョブを書きたいと思っています。再生フレームワークの呼び出しスケジュールされた非同期タスク内のWS
私は次のように2つのクラスを書いた:
@Singleton
public class AutoGateJob {
@Inject
private ActorSystem actorSystem;
@Inject
private ExecutionContext executionContext;
@Inject
private RgsDataServiceServices rgsDataServiceServices;
@Inject
public AutoGateJob(ApplicationLifecycle lifecycle, ActorSystem system, ExecutionContext
context) {
Logger.info("### create autojob");
this.actorSystem = system;
this.executionContext = context;
this.initialize();
lifecycle.addStopHook(() -> {
Logger.info("### c'est l'heure de rentrer!!!");
this.actorSystem.shutdown();
return CompletableFuture.completedFuture(null);
});
}
private void initialize() {
this.actorSystem.scheduler().schedule(
Duration.create(0, TimeUnit.SECONDS), // initialDelay
Duration.create(5, TimeUnit.SECONDS), // interval
() -> this.runAutoGateJobTasks(),
this.executionContext
);
}
private void runAutoGateJobTasks() {
Logger.info("## Run job every 5 seconds");
rgsDataServiceServices = new RgsDataServiceServices();
rgsDataServiceServices.findAllPaymentToSendHandler()
.handle((wsResponse, throwable) -> {
Logger.info("## find all payment to send response: ", wsResponse.asJson());
List<String> paymentsList = new ArrayList<>();
paymentsList.forEach(s -> {
Logger.info("## Processing payment: ", s);
});
return CompletableFuture.completedFuture(null);
});
}
}
と
public class AutoGateJobInitializer extends AbstractModule {
@Override
protected void configure() {
Logger.info("## Setup job on app startup!");
bind(AutoGateJob.class).asEagerSingleton();
}
}
を、問題がある: はMys rgsDataServiceServicesが働く作業WSClient注射を持っていますコントローラと一緒に使用するとうまくいくが、呼び出されたときAutoGateJobに私は、nullポインタ例外 ( [エラー] a.d.TaskInvocation - nullの のjava.lang.NullPointerException:ヌル )持って を私は本当に何が起こっているのか理解していないが、私はこのように動作するために私の仕事を必要としています。
ありがとうございました!