Бывает, что, может быть, мне нужно вызвать SOAP примерно 200 раз в зависимости от размера списка ... Поэтому я попытался использовать parallelStream
, чтобы быть быстрее. Традиционное решение с forEach
хорошо работало для небольших чисел, но мне нужно что-то для больших ... Некоторые имена на португальском языке, но не беспокойтесь об этом, представьте тогда как generi c "A" или "B" ".
public ConjuntoElegibilidadeDTO consultaElegibilidadePorEC(final List<Long> numerosEC) {
ConjuntoElegibilidadeDTO conjunto = new ConjuntoElegibilidadeDTO();
conjunto.setElegibilidadePorNumeroEC(new ArrayList<>());
ForkJoinPool customThreadPool = new ForkJoinPool(numerosEC.size());
customThreadPool.submit(() -> numerosEC.parallelStream().forEach(nuCustomer -> {
VerificarClienteExistenteRequestType request = new VerificarClienteExistenteRequestType();
request.setCodigoCliente(nuCustomer);
VerificarClienteExistenteResponseType resp = new VerificarClienteExistenteResponseType();
try {
resp = executeAndLogSoap(request, "verificarClienteExistente");
ClienteElegibilidadeDTO cliente = new ClienteElegibilidadeDTO();
cliente.setElegibilidade(resp.getIndicadorClienteExistente());
cliente.setNuEC(nuCustomer);
conjunto.getElegibilidadePorNumeroEC().add(cliente);
} catch (Exception e) {
log.error(e.getMessage());
}
}));
return conjunto;
}
И тогда я получил исключение (в этом списке было только 4 числа):
2020-03-31 21:59:26.283 INFO [app:fac-oferta-
service,traceId:6b4754fde17dfdce,spanId:6b4754fde17dfdce,zipkin:false] 1376 --- [http-nio-8082-exec-
5] b.c.c.l.a.CrmLogElapsedTimeAspect : Method execution(public
org.springframework.http.ResponseEntity
br.com.cielo.gv.simulador.controller.SimuladorMargemController.consultaElegibilidadePorEC()) with
args [] succeed in <200 OK OK,ConjuntoElegibilidadeDTO(elegibilidadePorNumeroEC=[]),[]>. Starts at
2020-03-31T21:59:26.283. Finish at 2020-03-31T21:59:26.283. Elapsed time is 0 milliseconds.
2020-03-31 21:59:26.305 ERROR [app:fac-oferta-service,traceId:,spanId:,zipkin:] 1376 ---
[ForkJoinPool-2-worker-1] b.c.c.s.ServiceAbstractEclipse : Method verificarClienteExistente starts at
2020-03-31T21:59:26.286 finished at 2020-03-31T21:59:26.305 with request {
"codigoCliente" : 2004060020
} and exception java.lang.NullPointerException in 19 miliseconds
2020-03-31 21:59:26.305 ERROR [app:fac-oferta-service,traceId:,spanId:,zipkin:] 1376 ---
[ForkJoinPool-2-worker-1] b.c.c.g.s.e.s.ElegibilidadeSimuladorService : null
2020-03-31 21:59:26.312 ERROR [app:fac-oferta-service,traceId:,spanId:,zipkin:] 1376 ---
[ForkJoinPool-2-worker-2] b.c.c.s.ServiceAbstractEclipse : Method verificarClienteExistente starts at
2020-03-31T21:59:26.297 finished at 2020-03-31T21:59:26.312 with request {
"codigoCliente" : 2000456983
} and exception java.lang.NullPointerException in 15 miliseconds
2020-03-31 21:59:26.312 ERROR [app:fac-oferta-service,traceId:,spanId:,zipkin:] 1376 ---
[ForkJoinPool-2-worker-2] b.c.c.g.s.e.s.ElegibilidadeSimuladorService : null
2020-03-31 21:59:26.316 ERROR [app:fac-oferta-service,traceId:,spanId:,zipkin:] 1376 ---
[ForkJoinPool-2-worker-3] b.c.c.s.ServiceAbstractEclipse : Method verificarClienteExistente starts at
2020-03-31T21:59:26.298 finished at 2020-03-31T21:59:26.316 with request {
"codigoCliente" : 2000150980
} and exception java.lang.NullPointerException in 18 miliseconds
2020-03-31 21:59:26.318 ERROR [app:fac-oferta-service,traceId:,spanId:,zipkin:] 1376 ---
[ForkJoinPool-2-worker-3] b.c.c.g.s.e.s.ElegibilidadeSimuladorService : null
2020-03-31 21:59:26.318 ERROR [app:fac-oferta-service,traceId:,spanId:,zipkin:] 1376 ---
[ForkJoinPool-2-worker-1] b.c.c.s.ServiceAbstractEclipse : Method verificarClienteExistente starts at
2020-03-31T21:59:26.306 finished at 2020-03-31T21:59:26.318 with request {
"codigoCliente" : 2000463023
} and exception java.lang.NullPointerException in 12 miliseconds
2020-03-31 21:59:26.319 ERROR [app:fac-oferta-service,traceId:,spanId:,zipkin:] 1376 ---
[ForkJoinPool-2-worker-1] b.c.c.g.s.e.s.ElegibilidadeSimuladorService : null