-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
72 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...ssors/src/main/kotlin/de/fhg/aisec/ids/camel/processors/ShutdownConfigurationProcessor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters