From 77d1ee4b87187c05f03bba40b5578cbf55a52f37 Mon Sep 17 00:00:00 2001 From: Matthew Horridge Date: Mon, 17 Jun 2024 14:21:31 -0700 Subject: [PATCH 1/6] Update workflows for auto-release --- .github/workflows/ci.yaml | 13 ++++++--- .github/workflows/pub.yaml | 29 -------------------- .github/workflows/release.yaml | 48 ++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 33 deletions(-) delete mode 100644 .github/workflows/pub.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f023adc..ad57177 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,6 +1,9 @@ -name: Java CI +name: Verify -on: [push] +on: + push: + branches-ignore: + - main jobs: build: @@ -8,10 +11,12 @@ jobs: steps: - uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} - name: Set up JDK 17 uses: actions/setup-java@v3 with: java-version: '17' - distribution: 'temurin' + distribution: 'adopt' - name: Build with Maven - run: mvn --batch-mode --update-snapshots package \ No newline at end of file + run: mvn --batch-mode verify diff --git a/.github/workflows/pub.yaml b/.github/workflows/pub.yaml deleted file mode 100644 index 6bff372..0000000 --- a/.github/workflows/pub.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: Publish package to the Maven Central Repository -on: - release: - types: [released] - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Maven Central Repository - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'adopt' - server-id: ossrh - server-username: OSSRH_USERNAME - server-password: OSSRH_TOKEN - gpg-private-key: ${{secrets.GPG_PRIVATE_KEY}} - gpg-passphrase: GPG_PASSPHRASE - - if: github.event.release - name: Update version in pom.xml (Release only) - run: mvn -B versions:set -DnewVersion=${{ github.event.release.tag_name }} -DgenerateBackupPoms=false - - name: Publish package - run: mvn --batch-mode -Prelease deploy -env: - GPG_PASSPHRASE: ${{secrets.GPG_PASSPHRASE}} - OSSRH_USERNAME: ${{secrets.OSSRH_USERNAME}} - OSSRH_TOKEN: ${{secrets.OSSRH_TOKEN}} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..1ebcaef --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,48 @@ +name: Release + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + if: ${{ github.actor != 'protegeproject-bot[bot]' }} + steps: + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.PROTEGEPROJECT_BOT_APP_ID }} + private-key: ${{ secrets.PROTEGEPROJECT_BOT_APP_PRIVATE_KEY }} + - uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + ref: ${{ github.head_ref }} + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + server-id: ossrh + server-username: OSSRH_USERNAME + server-password: OSSRH_TOKEN + gpg-private-key: ${{secrets.GPG_PRIVATE_KEY}} + gpg-passphrase: GPG_PASSPHRASE + - name: Bump version + id: bump + uses: mickem/gh-action-bump-maven-version@v1 + - name: Build with Maven + run: mvn --batch-mode -Prelease deploy + - name: Release + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.bump.outputs.tag }} + generate_release_notes: true + +env: + GPG_PASSPHRASE: ${{secrets.GPG_PASSPHRASE}} + OSSRH_USERNAME: ${{secrets.OSSRH_USERNAME}} + OSSRH_TOKEN: ${{secrets.OSSRH_TOKEN}} From 79e310f4beeadb1261e3ed6b29d49c37fd500f63 Mon Sep 17 00:00:00 2001 From: Matthew Horridge Date: Mon, 17 Jun 2024 15:24:18 -0700 Subject: [PATCH 2/6] Set time out in RabbitMq async rabbit template --- .../protege/webprotege/ipc/impl/RabbitMqConfiguration.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 f425d9f..1ac9f74 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 @@ -94,7 +94,11 @@ public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) { @Bean(name = "asyncRabbitTemplate") @ConditionalOnProperty(prefix = "webprotege.rabbitmq", name = "commands-subscribe", havingValue = "true", matchIfMissing = true) public AsyncRabbitTemplate asyncRabbitTemplate(@Qualifier("rabbitTemplate") RabbitTemplate rabbitTemplate, SimpleMessageListenerContainer replyListenerContainer) { - return new AsyncRabbitTemplate(rabbitTemplate, replyListenerContainer, getCommandResponseQueue()); + var asyncRabbitTemplate = new AsyncRabbitTemplate(rabbitTemplate, + replyListenerContainer, + getCommandResponseQueue()); + asyncRabbitTemplate.setReceiveTimeout(rabbitMqTimeout); + return asyncRabbitTemplate; } From 3e9a31540513d4d60907987d13d26cf31ba49759 Mon Sep 17 00:00:00 2001 From: Automated Version Bump Date: Mon, 17 Jun 2024 22:42:28 +0000 Subject: [PATCH 3/6] ci: version bump 1.0.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 63fc33e..87a119e 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ edu.stanford.protege webprotege-ipc - 1.0.3 + 1.0.4 webprotege-ipc Inter Process Communication framework From e0efc0715b991055e124a7b6446699dc916ea5ff Mon Sep 17 00:00:00 2001 From: silag Date: Mon, 24 Jun 2024 13:55:16 +0300 Subject: [PATCH 4/6] increase timeout --- pom.xml | 2 +- .../ipc/impl/CommandExecutorImpl.java | 2 +- .../ipc/impl/RabbitMQEventDispatcher.java | 1 - .../ipc/impl/RabbitMQEventHandlerWrapper.java | 1 - .../ipc/impl/RabbitMqCommandHandlerWrapper.java | 17 ++++++++++++++--- .../ipc/impl/RabbitMqConfiguration.java | 8 ++++++-- 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 63fc33e..de624ab 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ edu.stanford.protege webprotege-ipc - 1.0.3 + 1.0.5 webprotege-ipc Inter Process Communication framework 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 f425d9f..3d795e6 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 @@ -86,7 +86,7 @@ DirectExchange exchange() { @ConditionalOnProperty(prefix = "webprotege.rabbitmq", name = "commands-subscribe", havingValue = "true", matchIfMissing = true) public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) { RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory); - rabbitTemplate.setReplyTimeout(rabbitMqTimeout); + rabbitTemplate.setReplyTimeout(120000); rabbitTemplate.setExchange(COMMANDS_EXCHANGE); return rabbitTemplate; } @@ -94,7 +94,9 @@ public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) { @Bean(name = "asyncRabbitTemplate") @ConditionalOnProperty(prefix = "webprotege.rabbitmq", name = "commands-subscribe", havingValue = "true", matchIfMissing = true) public AsyncRabbitTemplate asyncRabbitTemplate(@Qualifier("rabbitTemplate") RabbitTemplate rabbitTemplate, SimpleMessageListenerContainer replyListenerContainer) { - return new AsyncRabbitTemplate(rabbitTemplate, replyListenerContainer, getCommandResponseQueue()); + AsyncRabbitTemplate response = new AsyncRabbitTemplate(rabbitTemplate, replyListenerContainer, getCommandResponseQueue()); + response.setReceiveTimeout(120000); + return response; } @@ -105,6 +107,7 @@ public SimpleMessageListenerContainer replyListenerContainer(ConnectionFactory c SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setConnectionFactory(connectionFactory); container.setQueues(replyQueue); + container.setConcurrency("15-20"); return container; } @@ -121,6 +124,7 @@ public SimpleMessageListenerContainer messageListenerContainers() { container.setQueueNames(getCommandQueue()); container.setConnectionFactory(connectionFactory); container.setMessageListener(rabbitMqCommandHandlerWrapper()); + container.setConcurrency("15-20"); return container; } From 8ed58fd30b5873e3ab9b8176546eb68c5f5da003 Mon Sep 17 00:00:00 2001 From: silag Date: Thu, 27 Jun 2024 18:39:16 +0300 Subject: [PATCH 5/6] removed hardcoded timeout --- .../webprotege/ipc/impl/RabbitMqConfiguration.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 3d795e6..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 @@ -86,7 +86,7 @@ DirectExchange exchange() { @ConditionalOnProperty(prefix = "webprotege.rabbitmq", name = "commands-subscribe", havingValue = "true", matchIfMissing = true) public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) { RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory); - rabbitTemplate.setReplyTimeout(120000); + rabbitTemplate.setReplyTimeout(rabbitMqTimeout); rabbitTemplate.setExchange(COMMANDS_EXCHANGE); return rabbitTemplate; } @@ -94,9 +94,11 @@ public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) { @Bean(name = "asyncRabbitTemplate") @ConditionalOnProperty(prefix = "webprotege.rabbitmq", name = "commands-subscribe", havingValue = "true", matchIfMissing = true) public AsyncRabbitTemplate asyncRabbitTemplate(@Qualifier("rabbitTemplate") RabbitTemplate rabbitTemplate, SimpleMessageListenerContainer replyListenerContainer) { - AsyncRabbitTemplate response = new AsyncRabbitTemplate(rabbitTemplate, replyListenerContainer, getCommandResponseQueue()); - response.setReceiveTimeout(120000); - return response; + var asyncRabbitTemplate = new AsyncRabbitTemplate(rabbitTemplate, + replyListenerContainer, + getCommandResponseQueue()); + asyncRabbitTemplate.setReceiveTimeout(rabbitMqTimeout); + return asyncRabbitTemplate; } From 4b030612e4f20115a74c687bb92f89fa523463da Mon Sep 17 00:00:00 2001 From: Automated Version Bump Date: Thu, 27 Jun 2024 18:29:04 +0000 Subject: [PATCH 6/6] ci: version bump 1.0.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 87a119e..de624ab 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ edu.stanford.protege webprotege-ipc - 1.0.4 + 1.0.5 webprotege-ipc Inter Process Communication framework