From 6c0daaaefc723d2f30d052e824c39496306032d9 Mon Sep 17 00:00:00 2001 From: Michael Lux Date: Mon, 27 Nov 2023 16:55:42 +0100 Subject: [PATCH] Improved examples --- .../processors/ArtifactRequestProcessor.kt | 2 +- .../ShutdownConfigurationProcessor.kt | 48 ++++++++++++++++++ .../src/main/resources/etc/settings.mapdb | Bin 2097152 -> 2097152 bytes .../example-idscp2-client.xml | 32 ++++++++---- .../example-idscp2-server.xml | 2 +- .../example-idscp2-client-broadcast.xml | 2 +- 6 files changed, 72 insertions(+), 14 deletions(-) create mode 100644 camel-processors/src/main/kotlin/de/fhg/aisec/ids/camel/processors/ShutdownConfigurationProcessor.kt diff --git a/camel-processors/src/main/kotlin/de/fhg/aisec/ids/camel/processors/ArtifactRequestProcessor.kt b/camel-processors/src/main/kotlin/de/fhg/aisec/ids/camel/processors/ArtifactRequestProcessor.kt index 281fb513..61a919e2 100644 --- a/camel-processors/src/main/kotlin/de/fhg/aisec/ids/camel/processors/ArtifactRequestProcessor.kt +++ b/camel-processors/src/main/kotlin/de/fhg/aisec/ids/camel/processors/ArtifactRequestProcessor.kt @@ -85,7 +85,7 @@ class ArtifactRequestProcessor : Processor { LOG.debug("Constructing RejectionMessage for requested artifact: {}", rejectionReason) } RejectionMessageBuilder() - ._correlationMessage_(artifactRequestMessage.correlationMessage) + ._correlationMessage_(artifactRequestMessage.id) ._rejectionReason_(rejectionReason) .let { if (LOG.isDebugEnabled) { diff --git a/camel-processors/src/main/kotlin/de/fhg/aisec/ids/camel/processors/ShutdownConfigurationProcessor.kt b/camel-processors/src/main/kotlin/de/fhg/aisec/ids/camel/processors/ShutdownConfigurationProcessor.kt new file mode 100644 index 00000000..276f9830 --- /dev/null +++ b/camel-processors/src/main/kotlin/de/fhg/aisec/ids/camel/processors/ShutdownConfigurationProcessor.kt @@ -0,0 +1,48 @@ +/*- + * ========================LICENSE_START================================= + * camel-processors + * %% + * Copyright (C) 2023 Fraunhofer AISEC + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package de.fhg.aisec.ids.camel.processors + +import org.apache.camel.Exchange +import org.apache.camel.Processor +import org.slf4j.LoggerFactory +import org.springframework.stereotype.Component + +/** + * This processor configures the shutdown timeout of the ShutdownStrategy in this context. + */ +@Component("shutdownConfigurationProcessor") +class ShutdownConfigurationProcessor : Processor { + override fun process(exchange: Exchange) { + if (LOG.isDebugEnabled) { + LOG.debug("[IN] ${this::class.java.simpleName}") + } + exchange.getProperty("timeout-seconds")?.let { + val seconds = it.toString().toLong() + if (LOG.isDebugEnabled) { + LOG.debug("Setting shutdown timeout to {} seconds...", seconds) + } + exchange.context.shutdownStrategy.timeout = seconds + } ?: LOG.warn("Property \"timeout-seconds\" not found, no change will be performed.") + } + + companion object { + private val LOG = LoggerFactory.getLogger(ShutdownConfigurationProcessor::class.java) + } +} diff --git a/examples/src/main/resources/etc/settings.mapdb b/examples/src/main/resources/etc/settings.mapdb index fa470c033236d0f0e1253da9cf62af6d74f5d8dd..e0e0e05d739f1f4d9c45fb2f739236b04f765060 100644 GIT binary patch delta 822 zcmchUxo#9N5Qep!;dT=4D-@fO3MmK#1p+~YltolL0Uaqof_e)}l$0*g(GT+2<7*pU zf(O8-M3Iu738bM&o8oJ1&-nXi=JWYvzK5L1Bl4&`CXdS#@}yjnr{rmQMxK@D`i76|oTwDj1S_|4?kIpD)BOwevuj=?KV;DM7=*H6=DE z-4PVi2M+Yr#T2+^F`2SRs+kCE)NImHfaq)i8`#{$LAuf3_Tla`ac80)Jr^?-9*ghm zC1I(-H!z`Vpkxgc$KP2WQqtArX!L#tY}T1-9kiAk@E8!1uK~Or&1+4K9sbYoRDF6P zwht$W^RI(H-cJ>wJe*_hW#MD6dXNND8%EW*a}4K30#TjhNWI(|2HjO z#?It0{NJjVTjJgdBJbe`x`opVYrdhe>dTh+c)A$J#ndLF*lYGX$AW<$JR?^si*Jpv|c!F$~yw%B0= - - + + - + + + + + 10 + + + + + + + https://example.com/some_artifact @@ -43,21 +54,19 @@ - - - ${null} + + - - - ${null} + + - + https://example.com/some_artifact @@ -72,7 +81,8 @@ - + + diff --git a/examples/src/main/resources/example-idscp2-uc/example-idscp2-server.xml b/examples/src/main/resources/example-idscp2-uc/example-idscp2-server.xml index 6aa012c1..116a3406 100644 --- a/examples/src/main/resources/example-idscp2-uc/example-idscp2-server.xml +++ b/examples/src/main/resources/example-idscp2-uc/example-idscp2-server.xml @@ -48,7 +48,7 @@ - + diff --git a/examples/src/main/resources/example-idscp2/example-idscp2-client-broadcast.xml b/examples/src/main/resources/example-idscp2/example-idscp2-client-broadcast.xml index 90e2b142..ea5fe98f 100644 --- a/examples/src/main/resources/example-idscp2/example-idscp2-client-broadcast.xml +++ b/examples/src/main/resources/example-idscp2/example-idscp2-client-broadcast.xml @@ -18,7 +18,7 @@ - +