From 7c9c364b6c081ecf27d60620feca1e97ce330f53 Mon Sep 17 00:00:00 2001 From: dominikhorn Date: Thu, 30 Nov 2023 09:00:58 +0100 Subject: [PATCH 1/3] fix: camunda 7 worker retries --- .../connect/adapter/in/c7/worker/Camunda7WorkerAdapter.java | 2 +- .../src/main/resources/application.properties | 1 - .../src/main/resources/bpmn/message-c7.bpmn | 4 ++-- stack/camunda-7/docker-compose.yml | 5 +++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/connect/connect-c7/worker-adapter-c7/src/main/java/io/miragon/miranum/connect/adapter/in/c7/worker/Camunda7WorkerAdapter.java b/connect/connect-c7/worker-adapter-c7/src/main/java/io/miragon/miranum/connect/adapter/in/c7/worker/Camunda7WorkerAdapter.java index 37b3c03cf..d1a7907a8 100644 --- a/connect/connect-c7/worker-adapter-c7/src/main/java/io/miragon/miranum/connect/adapter/in/c7/worker/Camunda7WorkerAdapter.java +++ b/connect/connect-c7/worker-adapter-c7/src/main/java/io/miragon/miranum/connect/adapter/in/c7/worker/Camunda7WorkerAdapter.java @@ -49,7 +49,7 @@ public void execute(final WorkerExecutor executor, final ExternalTask externalTa } catch (final Exception error) { int retries = getRemainingRetries(externalTask.getRetries(), workerRetries); log.severe("Error while executing external task " + error.getMessage()); - service.handleFailure(externalTask, error.getMessage(), Arrays.toString(error.getStackTrace()), retries, 5000L); + service.handleFailure(externalTask, error.getMessage(), Arrays.toString(error.getStackTrace()), retries -1, 5000L); } } diff --git a/examples/simple-example/simple-example-camunda-7/src/main/resources/application.properties b/examples/simple-example/simple-example-camunda-7/src/main/resources/application.properties index 960962548..2a079d3c0 100644 --- a/examples/simple-example/simple-example-camunda-7/src/main/resources/application.properties +++ b/examples/simple-example/simple-example-camunda-7/src/main/resources/application.properties @@ -1,7 +1,6 @@ server.port=9090 camunda.bpm.client.base-url=http://localhost:8080/engine-rest camunda.bpm.client.disable-backoff-strategy=true -camunda.autoDeploy.enabled=false #logging.level.root=DEBUG #miranum.c7.auth.server.url=http://localhost:8080/auth/realms/forms-flow-ai/protocol/openid-connect/token #miranum.c7.client.id=test-client diff --git a/examples/simple-example/simple-example-camunda-7/src/main/resources/bpmn/message-c7.bpmn b/examples/simple-example/simple-example-camunda-7/src/main/resources/bpmn/message-c7.bpmn index 61a583206..5ac820d55 100644 --- a/examples/simple-example/simple-example-camunda-7/src/main/resources/bpmn/message-c7.bpmn +++ b/examples/simple-example/simple-example-camunda-7/src/main/resources/bpmn/message-c7.bpmn @@ -1,6 +1,6 @@ - - + + Flow_0yx0bta diff --git a/stack/camunda-7/docker-compose.yml b/stack/camunda-7/docker-compose.yml index f83259b99..d7ff917e6 100644 --- a/stack/camunda-7/docker-compose.yml +++ b/stack/camunda-7/docker-compose.yml @@ -1,7 +1,8 @@ # Use this only in dev environments. It's not intended for production usage. version: '3' services: - camunda: - image: camunda/camunda-bpm-platform:7.18.0 + camunda-miranum: + image: camunda/camunda-bpm-platform:7.20.0 + container_name: camunda-miranum ports: - "8080:8080" From 448f733f2c02e8ac493f3d73db22259f862b45ff Mon Sep 17 00:00:00 2001 From: dominikhorn Date: Thu, 30 Nov 2023 09:04:17 +0100 Subject: [PATCH 2/3] fix: increase revision --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fd9917ba1..13e514b49 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ https://github.com/flowsquad/miranum-connect - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT 17 17 3.13.0 From 71e4151ce95dd35db1a7c38934b4409c1aa1179b Mon Sep 17 00:00:00 2001 From: dominikhorn Date: Thu, 30 Nov 2023 09:16:28 +0100 Subject: [PATCH 3/3] fix: increase revision --- .../adapter/in/c7/worker/Camunda7WorkerAdapter.java | 10 +++++++--- .../adapter/in/c7/worker/Camunda7AdapterTest.java | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/connect/connect-c7/worker-adapter-c7/src/main/java/io/miragon/miranum/connect/adapter/in/c7/worker/Camunda7WorkerAdapter.java b/connect/connect-c7/worker-adapter-c7/src/main/java/io/miragon/miranum/connect/adapter/in/c7/worker/Camunda7WorkerAdapter.java index d1a7907a8..bef679a45 100644 --- a/connect/connect-c7/worker-adapter-c7/src/main/java/io/miragon/miranum/connect/adapter/in/c7/worker/Camunda7WorkerAdapter.java +++ b/connect/connect-c7/worker-adapter-c7/src/main/java/io/miragon/miranum/connect/adapter/in/c7/worker/Camunda7WorkerAdapter.java @@ -49,7 +49,7 @@ public void execute(final WorkerExecutor executor, final ExternalTask externalTa } catch (final Exception error) { int retries = getRemainingRetries(externalTask.getRetries(), workerRetries); log.severe("Error while executing external task " + error.getMessage()); - service.handleFailure(externalTask, error.getMessage(), Arrays.toString(error.getStackTrace()), retries -1, 5000L); + service.handleFailure(externalTask, error.getMessage(), Arrays.toString(error.getStackTrace()), retries, 5000L); } } @@ -66,11 +66,15 @@ public void execute(final WorkerExecutor executor, final ExternalTask externalTa * @return The remaining number of retries for the task. */ private int getRemainingRetries(Integer externalTaskRetries, Integer workerRetries) { + int retries = 0; if (Objects.isNull(externalTaskRetries)) { - return Objects.isNull(workerRetries) ? + retries = Objects.isNull(workerRetries) ? camunda7WorkerProperties.getDefaultRetries() : workerRetries; + }else { + retries = externalTaskRetries; } - return externalTaskRetries; + retries -= 1; + return Math.max(retries, 0); } } \ No newline at end of file diff --git a/connect/connect-c7/worker-adapter-c7/src/test/java/io/miragon/miranum/connect/adapter/in/c7/worker/Camunda7AdapterTest.java b/connect/connect-c7/worker-adapter-c7/src/test/java/io/miragon/miranum/connect/adapter/in/c7/worker/Camunda7AdapterTest.java index 99ecb5e5d..95a38ef61 100644 --- a/connect/connect-c7/worker-adapter-c7/src/test/java/io/miragon/miranum/connect/adapter/in/c7/worker/Camunda7AdapterTest.java +++ b/connect/connect-c7/worker-adapter-c7/src/test/java/io/miragon/miranum/connect/adapter/in/c7/worker/Camunda7AdapterTest.java @@ -87,7 +87,7 @@ void givenDefaultUseCaseAndRetriesProvided_thenInvokeGetRemainingRetries() throw var retriesCaptor = ArgumentCaptor.forClass(Integer.class); then(service).should().handleFailure((ExternalTask) any(), any(), any(), retriesCaptor.capture(), anyLong()); - assertEquals(3, retriesCaptor.getValue()); + assertEquals(3-1, retriesCaptor.getValue()); } @Test @@ -101,7 +101,7 @@ void givenDefaultUseCaseAndRetriesSetInBpmn_thenUseBpmnRetries() { adapter.execute(defaultWorker, externalTask, service); - then(service).should().handleFailure((ExternalTask) any(), any(), any(), eq(bpmnRetries), anyLong()); + then(service).should().handleFailure((ExternalTask) any(), any(), any(), eq(bpmnRetries-1), anyLong()); } @Test @@ -117,7 +117,7 @@ void givenDefaultUseCaseAndRetriesSetInWorkerInput_thenUseWorkerRetries() { adapter.execute(defaultWorker, externalTask, service); - then(service).should().handleFailure((ExternalTask) any(), any(), any(), eq(workerRetries), anyLong()); + then(service).should().handleFailure((ExternalTask) any(), any(), any(), eq(workerRetries-1), anyLong()); } @Test @@ -131,7 +131,7 @@ void givenDefaultUseCaseAndNoRetriesProvided_thenUseDefaultRetries() { adapter.execute(defaultWorker, externalTask, service); - then(service).should().handleFailure((ExternalTask) any(), any(), any(), eq(defaultRetries), anyLong()); + then(service).should().handleFailure((ExternalTask) any(), any(), any(), eq(defaultRetries-1), anyLong()); } @Test