Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
# Conflicts:
#	pom.xml
#	src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMqConfiguration.java
  • Loading branch information
alexsilaghi committed Nov 12, 2024
2 parents c291664 + 4b03061 commit 0a1743a
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 39 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
name: Java CI
name: Verify

on: [push]
on:
push:
branches-ignore:
- main

jobs:
build:
runs-on: ubuntu-latest

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
run: mvn --batch-mode verify
29 changes: 0 additions & 29 deletions .github/workflows/pub.yaml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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}}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public RabbitMQEventHandlerWrapper(List<EventHandler<? extends Event>> 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public RabbitMqCommandHandlerWrapper(List<CommandHandler<? extends Request, ? ex

@Override
public void onMessage(Message message, Channel channel) throws Exception {
logger.info("Received message " + message);

var replyChannel = message.getMessageProperties().getReplyTo();
if (replyChannel == null) {
String errorMessage = Headers.REPLY_CHANNEL + " header is missing. Cannot reply to message.";
Expand Down Expand Up @@ -86,7 +84,6 @@ public void onMessage(Message message, Channel channel) throws Exception {
}

CommandHandler handler = extractHandler(messageType);
logger.info("Dispatch handling to {}", handler.getClass());
parseAndHandleRequest(handler, message, channel, new UserId(userId), accessToken);
}

Expand Down Expand Up @@ -171,10 +168,15 @@ private void authorizeAndReplyToRequest(CommandHandler<Q,R> handler,

private void handleAndReplyToRequest(CommandHandler<Q,R> 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(
Expand All @@ -183,14 +185,23 @@ private void handleAndReplyToRequest(CommandHandler<Q,R> 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");

}
}

Expand Down

0 comments on commit 0a1743a

Please sign in to comment.