Interface JobExecutionAsyncApi
-
public interface JobExecutionAsyncApiThis interfaces exposes an event source,JobEventSource, that emits events to which a client application can subscribe to.
It differs from
Below an example that shows how to get aJobExecutionSharedAsyncApias it allows multiple clients to get all events of jobs (events are not balanced).JobEventSourcefor a particular job:
Then, you can use theString jobId = "theJobToListen"; CompletableFuture<Void> onComplete = new CompletableFuture<>(); onComplete.whenComplete((v, e) -> LOGGER.info("The flow of events for this job is finished")); JobEventSource eventSource = jobExecutionAsyncApi.getJobEventSource( new JobSubscriptionFilter(jobId) );JobEventSource's methods.- See Also:
JobEventSource,JobExecutionSharedAsyncApi
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description JobEventSourcegetJobEventSource(JobSubscriptionFilter filter)Returns a connectable job event source the client can subscribe to.default java.util.concurrent.CompletionStage<com.decisionbrain.optimserver.master.model.JobSolution>getJobSolution(java.lang.String jobId, java.time.Duration timeout)Waits for the job identified byjobIdto terminate and return the computed solution.
-
-
-
Method Detail
-
getJobSolution
default java.util.concurrent.CompletionStage<com.decisionbrain.optimserver.master.model.JobSolution> getJobSolution(java.lang.String jobId, java.time.Duration timeout)Waits for the job identified byjobIdto terminate and return the computed solution.This method is a shortcut for {
JobEventSource.jobSolution()}- Parameters:
jobId- The job identifier to get the solution from.timeout- The maximum amount of time to wait before completing the CompletionStage with aTimeoutException- Returns:
- A
CompletionStagewith either the computed job solution or aTimeoutException
-
getJobEventSource
JobEventSource getJobEventSource(JobSubscriptionFilter filter)
Returns a connectable job event source the client can subscribe to.If the filter parameter field 'jobId' is set, only the events of the corresponding job are emitted as the source is connected. If the 'jobId' is not set, the events of all the jobs are emitted.
All clients that use the same job id receive all events of the job. For instance, if two applications listen the job solution for the same job id, both will receive the
JobSolutionof the job.- Parameters:
filter- To filter the events emitted by this source.- Returns:
- A connectable job event source the client can subscribe to.
-
-