diff --git a/src/main/java/edu/stanford/protege/webprotege/ipc/impl/CommandExecutorImpl.java b/src/main/java/edu/stanford/protege/webprotege/ipc/impl/CommandExecutorImpl.java index dded056..8ae293b 100644 --- a/src/main/java/edu/stanford/protege/webprotege/ipc/impl/CommandExecutorImpl.java +++ b/src/main/java/edu/stanford/protege/webprotege/ipc/impl/CommandExecutorImpl.java @@ -65,7 +65,7 @@ private R handleResponse(Message rabbitResponse) { if(exception != null) { try { - logger.error("Found error on response " + exception); + logger.error("Found error on response {}. Action : {}" ,exception, rabbitResponse.getMessageProperties().getHeaders().get(Headers.METHOD)); throw objectMapper.readValue(exception, CommandExecutionException.class); } catch (JsonProcessingException e) { logger.error("Error ", e); diff --git a/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMQEventDispatcher.java b/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMQEventDispatcher.java index c412b4a..5b33419 100644 --- a/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMQEventDispatcher.java +++ b/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMQEventDispatcher.java @@ -51,7 +51,6 @@ public void dispatchEvent(Event event) { message.getMessageProperties().getHeaders().put(PROJECT_ID, projectId); } eventRabbitTemplate.convertAndSend(RabbitMQEventsConfiguration.EVENT_EXCHANGE, "", message); - logger.info("Sent event message!"); } catch (JsonProcessingException | AmqpException e) { logger.info("Could not serialize event: {}", e.getMessage(), e); } diff --git a/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMQEventHandlerWrapper.java b/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMQEventHandlerWrapper.java index 51b527c..ea1417b 100644 --- a/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMQEventHandlerWrapper.java +++ b/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMQEventHandlerWrapper.java @@ -28,7 +28,6 @@ public RabbitMQEventHandlerWrapper(List> eventHand @Override public void onMessage(Message message) { - logger.info("Handling event with id {}", message.getMessageProperties().getMessageId()); EventHandler eventHandler = eventHandlers.stream() .filter(handler -> { String channel = String.valueOf(message.getMessageProperties().getHeaders().get(CHANNEL)); diff --git a/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMqCommandHandlerWrapper.java b/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMqCommandHandlerWrapper.java index f2ea7ad..e722a99 100644 --- a/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMqCommandHandlerWrapper.java +++ b/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMqCommandHandlerWrapper.java @@ -46,8 +46,6 @@ public RabbitMqCommandHandlerWrapper(List handler, private void handleAndReplyToRequest(CommandHandler handler, Channel channel, Message message, UserId userId, Q request, String accessToken) { var executionContext = new ExecutionContext(userId, accessToken); + long startTime = System.currentTimeMillis(); + try { var response = handler.handleRequest(request, executionContext); response.subscribe(r -> { replyWithSuccessResponse(channel, message, userId, r); + long endtime = System.currentTimeMillis(); + logger.info("Request executed " + request.getChannel() + ". Time taken for Execution is : " + (endtime-startTime) +"ms"); + }, throwable -> { if (throwable instanceof CommandExecutionException ex) { logger.info( @@ -183,14 +185,23 @@ private void handleAndReplyToRequest(CommandHandler handler, Channel channe throwable.getMessage(), request); replyWithErrorResponse(message,channel, userId, ex.getStatus()); + long endtime = System.currentTimeMillis(); + logger.info("Request failed " + request.getChannel() + "with error " + throwable.getMessage() + ". Time taken for Execution is : " + (endtime-startTime) +"ms"); } else { replyWithErrorResponse(message, channel, userId, HttpStatus.INTERNAL_SERVER_ERROR); + long endtime = System.currentTimeMillis(); + + logger.info("Request failed " + request.getChannel() + "with error " + throwable.getMessage() + ". Time taken for Execution is : " + (endtime-startTime) +"ms"); + } }); } catch (Throwable throwable) { logger.error("Uncaught exception when handling request", throwable); replyWithErrorResponse(message, channel, userId, HttpStatus.INTERNAL_SERVER_ERROR); + long endtime = System.currentTimeMillis(); + logger.info("Request failed " + request.getChannel() + ". Time taken for Execution is : " + (endtime-startTime) +"ms"); + } } diff --git a/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMqConfiguration.java b/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMqConfiguration.java index 1ac9f74..d65668e 100644 --- a/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMqConfiguration.java +++ b/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMqConfiguration.java @@ -109,6 +109,7 @@ public SimpleMessageListenerContainer replyListenerContainer(ConnectionFactory c SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setConnectionFactory(connectionFactory); container.setQueues(replyQueue); + container.setConcurrency("15-20"); return container; } @@ -125,6 +126,7 @@ public SimpleMessageListenerContainer messageListenerContainers() { container.setQueueNames(getCommandQueue()); container.setConnectionFactory(connectionFactory); container.setMessageListener(rabbitMqCommandHandlerWrapper()); + container.setConcurrency("15-20"); return container; }