From 856083474f2c9f0a577c359296f22ae89f57fefc Mon Sep 17 00:00:00 2001 From: SrdjanStevanetic Date: Wed, 15 May 2024 12:01:10 +0200 Subject: [PATCH] return exception in case of the eTransl error callback --- .../etranslation/ETranslationTranslationService.java | 6 +++++- .../service/etranslation/RedisMessageListener.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/translation-service-etranslation/src/main/java/eu/europeana/api/translation/service/etranslation/ETranslationTranslationService.java b/translation-service-etranslation/src/main/java/eu/europeana/api/translation/service/etranslation/ETranslationTranslationService.java index 9c82f50a..5078ca63 100644 --- a/translation-service-etranslation/src/main/java/eu/europeana/api/translation/service/etranslation/ETranslationTranslationService.java +++ b/translation-service-etranslation/src/main/java/eu/europeana/api/translation/service/etranslation/ETranslationTranslationService.java @@ -166,7 +166,11 @@ private void createRedisMessageListenerAndWaitForResults(List tr if(LOGGER.isDebugEnabled()) { LOGGER.debug("Received message from redis message listener is: {}", response); } - if(response!=null) { + if(response.contains(ETranslationTranslationService.eTranslationErrorCallbackIndicator)) { + //eTtransl error callback received + throw new TranslationException(response); + } + else if(response!=null) { //extractTranslationsFromETranslationHtmlResponse(translationObjs, redisMessageListenerAdapter, response); extractTranslationsFromETranslationResponse(translationObjs, redisMessageListenerAdapter, response); } diff --git a/translation-service-etranslation/src/main/java/eu/europeana/api/translation/service/etranslation/RedisMessageListener.java b/translation-service-etranslation/src/main/java/eu/europeana/api/translation/service/etranslation/RedisMessageListener.java index 7a11252f..47f8f73d 100644 --- a/translation-service-etranslation/src/main/java/eu/europeana/api/translation/service/etranslation/RedisMessageListener.java +++ b/translation-service-etranslation/src/main/java/eu/europeana/api/translation/service/etranslation/RedisMessageListener.java @@ -23,7 +23,7 @@ public void onMessage(Message message, byte[] pattern) { String messageBody=new String(message.getBody(), StandardCharsets.UTF_8); if(messageBody.contains(ETranslationTranslationService.eTranslationErrorCallbackIndicator)) { //if we enter here, means the eTranslation error callback is called - this.message=null; + this.message=messageBody; } else { /*