Как поймать NoRouteToHostException и остановить выполнение процесса при разрешении, если возникают другие исключения - PullRequest
0 голосов
/ 05 августа 2020

У меня есть метод, который вызывает внешнюю веб-службу.

try {
            ResponseType = ExternalWebServicePort.getInstitutionID(Request);
            //setting values

        } catch (Exception e) {
            log.info("Exception occured while calling the service " +e.getLocalizedMessage());
            //setting response null and error as true
            try {
                throw new BatchJobException("Exception occured while calling the service for institution number: "+instNr+" with exception: "+e.getLocalizedMessage());
            } catch (BatchJobException e1) {
                log.info("Error while throwing BatchJobException ");
                e1.printStackTrace();
            }

и из другого класса Caller я сделал @Transactional dontRollbackOn = BatchJobException.class, чтобы он пропустил и продолжил процесс. Это отлично. В журналах выбрасывается исключение NoRouteToHostException, и процесс завершается. Я хочу перехватить NoRouteToHostException и заставить процесс завершиться ошибкой.

...