diff --git a/provider/indexer-aws/indexer-queue-aws/pom.xml b/provider/indexer-aws/indexer-queue-aws/pom.xml index d87eeef434fa2d10ae8cc9b47069a61d4c9a5473..6bf15e8ad88104720cb57ab54769a639d7fa6508 100644 --- a/provider/indexer-aws/indexer-queue-aws/pom.xml +++ b/provider/indexer-aws/indexer-queue-aws/pom.xml @@ -81,6 +81,16 @@ <artifactId>log4j-api</artifactId> <version>2.12.1</version> </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + <version>1.7.28</version> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-to-slf4j</artifactId> + <version>2.12.1</version> + </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> diff --git a/provider/indexer-aws/indexer-queue-aws/src/main/java/org/opengroup/osdu/indexerqueue/aws/api/IndexerQueue.java b/provider/indexer-aws/indexer-queue-aws/src/main/java/org/opengroup/osdu/indexerqueue/aws/api/IndexerQueue.java index 0aa2d1ab7c8bc45adabe2f62fe93105acd6b4861..50d387c521720b927a4aa7b8d451c46da2b0d006 100644 --- a/provider/indexer-aws/indexer-queue-aws/src/main/java/org/opengroup/osdu/indexerqueue/aws/api/IndexerQueue.java +++ b/provider/indexer-aws/indexer-queue-aws/src/main/java/org/opengroup/osdu/indexerqueue/aws/api/IndexerQueue.java @@ -49,57 +49,62 @@ public class IndexerQueue { AWSLogs log = logConfig.AmazonLog(); PutLogEventsRequest logRequest = new PutLogEventsRequest("ECSLogGroup-indexer-queue", "indexer-queue", new ArrayList<>()); - try { // Logger log = LogManager.getLogger(IndexerQueue.class); InputLogEvent logEvent = new InputLogEvent().withMessage("Starting Indexer Queue and obtaining Arguments"); logRequest.getLogEvents().add(logEvent); // log.debug("Retrieving indexer service account JWT"); + + + try { + // log.debug("Starting Indexer Queue and obtaining Arguments"); + + // log.debug("Retrieving indexer service account JWT"); AWSCognitoClient cognitoClient = new AWSCognitoClient(environmentVariables.cognitoClientId, environmentVariables.cognitoAuthFlow, environmentVariables.cognitoUser, environmentVariables.cognitoPassword); String indexerServiceAccountJWT = cognitoClient.getToken(); if(indexerServiceAccountJWT == null){ -// log.error("Indexer service account not set up correctly"); + // log.error("Indexer service account not set up correctly"); } -// log.debug(String.format("Connecting to the SQS Queue: %s", environmentVariables.queueName)); + // log.debug(String.format("Connecting to the SQS Queue: %s", environmentVariables.queueName)); AmazonSQSConfig sqsConfig = new AmazonSQSConfig(environmentVariables.region); AmazonSQS sqsClient = sqsConfig.AmazonSQS(); -// log.debug(String.format("Creating a thread pool with %s threads", environmentVariables.maxIndexThreads)); + // log.debug(String.format("Creating a thread pool with %s threads", environmentVariables.maxIndexThreads)); ThreadPoolExecutor executorPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(environmentVariables.maxIndexThreads); final String deadLetterQueueUrl = sqsClient.getQueueUrl(environmentVariables.deadLetterQueueName).getQueueUrl(); List<Message> messages = IndexerQueueService.getMessages(sqsClient, environmentVariables.queueName, environmentVariables.maxBatchRequestCount, environmentVariables.maxMessagesAllowed); -// log.debug(String.format("Processing %s messages from storage queue", messages.size())); + // log.debug(String.format("Processing %s messages from storage queue", messages.size())); if (!messages.isEmpty()) { List<IndexProcessor> indexProcessors = IndexerQueueService.processQueue(messages, environmentVariables.targetURL, executorPool, indexerServiceAccountJWT); -// log.debug(String.format("%s Messages Processed", indexProcessors.size())); + // log.debug(String.format("%s Messages Processed", indexProcessors.size())); List<IndexProcessor> failedProcessors = indexProcessors.stream().filter(indexProcessor -> indexProcessor.result == CallableResult.Fail || indexProcessor.exception != null).collect(Collectors.toList()); -// log.debug(String.format("%s Messages Failed", failedProcessors.size())); + // log.debug(String.format("%s Messages Failed", failedProcessors.size())); List<SendMessageResult> deadLetterResults = IndexerQueueService.sendMsgsToDeadLetterQueue(deadLetterQueueUrl, failedProcessors, sqsClient); -// log.debug(String.format("%s Messages Dead Lettered", deadLetterResults.size())); + // log.debug(String.format("%s Messages Dead Lettered", deadLetterResults.size())); List<DeleteMessageBatchRequestEntry> deleteEntries = indexProcessors.stream().map(indexProcessor -> new DeleteMessageBatchRequestEntry(indexProcessor.messageId, indexProcessor.receiptHandle)).collect(Collectors.toList()); -// log.debug(String.format("%s Messages Deleting", deleteEntries.size())); + // log.debug(String.format("%s Messages Deleting", deleteEntries.size())); final String sqsQueueUrl = sqsClient.getQueueUrl(environmentVariables.queueName).getQueueUrl(); List<DeleteMessageBatchRequest> deleteBatchRequests = IndexerQueueService.createMultipleBatchDeleteRequest(sqsQueueUrl, deleteEntries, environmentVariables.maxBatchRequestCount); -// log.debug(String.format("%s Delete Batch Request Created", deleteBatchRequests.size())); + // log.debug(String.format("%s Delete Batch Request Created", deleteBatchRequests.size())); List<DeleteMessageBatchResult> deleteMessageBatchResults = IndexerQueueService.deleteMessages(deleteBatchRequests, sqsClient); -// log.debug(String.format("%s Requests Deleted", deleteMessageBatchResults.size())); + // log.debug(String.format("%s Requests Deleted", deleteMessageBatchResults.size())); } } catch (ExecutionException e) { -// log.error(e.getMessage(), e); + // log.error(e.getMessage(), e); } catch (InterruptedException e) { -// log.error(e.getMessage(), e); + // log.error(e.getMessage(), e); } catch (NullPointerException e) { -// log.error(e.getMessage(), e); + // log.error(e.getMessage(), e); }catch (Exception e) { // log.error(e.getMessage(), e); } finally { @@ -107,6 +112,4 @@ public class IndexerQueue { log.putLogEvents(logRequest); } } - - }