use of org.eclipse.microprofile.context.ManagedExecutor in project quarkus-jberet by quarkiverse.
the class JBeretRecorder method initJobOperator.
public void initJobOperator(final JBeretConfig config, final ThreadPoolConfig threadPoolConfig, final BeanContainer beanContainer) {
ManagedExecutor managedExecutor = beanContainer.instance(ManagedExecutor.class);
TransactionManager transactionManager = beanContainer.instance(TransactionManager.class);
QuarkusJobOperator operator = new QuarkusJobOperator(config, threadPoolConfig, managedExecutor, transactionManager, JBeretDataHolder.getJobs());
JobOperatorContext operatorContext = JobOperatorContext.create(operator);
JobOperatorContext.setJobOperatorContextSelector(() -> operatorContext);
}
use of org.eclipse.microprofile.context.ManagedExecutor in project mega by Gepardec.
the class EmployeeServiceImpl method updateEmployeesReleaseDate.
@Override
public List<String> updateEmployeesReleaseDate(List<Employee> employees) {
final List<String> failedUserIds = new LinkedList<>();
/*
workaround until we can configure the managed executor in quarkus environment.
at the moment, employees list is partitioned by 10 and therefore 10 requests to zep are started at a time.
*/
Iterables.partition(Optional.ofNullable(employees).orElseThrow(() -> new ZepServiceException("no employees to update")), employeeUpdateParallelExecutions).forEach((partition) -> {
try {
CompletableFuture.allOf(partition.stream().map((employee) -> CompletableFuture.runAsync(() -> updateEmployeeReleaseDate(employee.getUserId(), employee.getReleaseDate()), managedExecutor).handle((aVoid, throwable) -> {
Optional.ofNullable(throwable).ifPresent((t) -> {
logger.error(String.format("error updating %s", employee.getUserId()), t);
failedUserIds.add(employee.getUserId());
});
return null;
})).toArray(CompletableFuture[]::new)).get();
} catch (ExecutionException e) {
logger.error("error updating employees", e);
failedUserIds.addAll(getUserIds(partition));
} catch (InterruptedException e) {
logger.error("error updating employees", e);
failedUserIds.addAll(getUserIds(partition));
Thread.currentThread().interrupt();
}
});
return failedUserIds;
}
use of org.eclipse.microprofile.context.ManagedExecutor in project kogito-runtimes by kiegroup.
the class RestClientBuilderFactory method build.
public static RestClientBuilder build(Class<?> restClass) {
RegisterRestClient annotation = restClass.getAnnotation(RegisterRestClient.class);
RestClientBuilderFactory instance = new RestClientBuilderFactory(restClass, annotation.baseUri(), annotation.configKey());
RestClientBuilder builder = RestClientBuilder.newBuilder();
instance.configureBaseUrl(builder);
instance.configureTimeouts(builder);
instance.configureProviders(builder);
instance.configureSsl(builder);
instance.configureProxy(builder);
instance.configureRedirects(builder);
instance.configureQueryParamStyle(builder);
instance.configureCustomProperties(builder);
// If we have context propagation, then propagate context to the async client threads
InstanceHandle<ManagedExecutor> managedExecutor = Arc.container().instance(ManagedExecutor.class);
if (managedExecutor.isAvailable()) {
builder.executorService(managedExecutor.get());
}
return builder;
}
Aggregations