Skip to content

Commit

Permalink
Camel
Browse files Browse the repository at this point in the history
  • Loading branch information
GuiWar committed May 6, 2024
1 parent 412f50a commit db06a96
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions server/alpha-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ dependencies {
testImplementation("global.genesis:genesis-dataserver2")
testImplementation("global.genesis:genesis-pal-dataserver")
testImplementation("global.genesis:genesis-pal-eventhandler")
api("org.apache.camel:camel-ftp")
api("org.apache.camel:camel-core")
}

description = "alpha-app"
Expand Down
11 changes: 11 additions & 0 deletions server/alpha-app/src/main/genesis/cfg/alpha-processes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,15 @@
<script>alpha-streamer-client.kts</script>
<language>pal</language>
</process>
<process name="ALPHA_CAMEL">
<groupId>ALPHA</groupId>
<start>true</start>
<options>-Xmx512m -DRedirectStreamsToLog=true -DXSD_VALIDATE=false</options>
<module>genesis-pal-camel</module>
<package>global.genesis.camel.pal</package>
<script>alpha-camel.kts</script>
<description>Alpha Camel integrations</description>
<classpath>alpha-app*</classpath>
<language>pal</language>
</process>
</processes>
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
<service host="localhost" name="ALPHA_DATAPIPELINE" port="11005"/>
<service host="localhost" name="ALPHA_STREAMER" port="11006"/>
<service host="localhost" name="ALPHA_STREAMER_CLIENT" port="11007"/>
<service host="localhost" name="ALPHA_CAMEL" port="11008"/>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ systemDefinition {
item(name = "ADMIN_PERMISSION_ENTITY_TABLE", value = "COUNTERPARTY")
item(name = "ADMIN_PERMISSION_ENTITY_FIELD", value = "COUNTERPARTY_ID")
item(name = "NULLABILITY_FOR_TRADE_FIELDS", value = false)
item(name = "SFTP_USERNAME", value = "JohnDoe")
item(name = "SFTP_PASSWORD", value = "Password11")
}

systems {
Expand Down
30 changes: 30 additions & 0 deletions server/alpha-app/src/main/genesis/scripts/alpha-camel.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import java.io.File
import global.genesis.commons.standards.GenesisPaths
import org.apache.camel.support.processor.idempotent.FileIdempotentRepository

camel {
val pathFromSftp = "${GenesisPaths.runtime()}inbound/"
LOG.info("#### About to create or make sure the dir is there: '$pathFromSftp' ####")
try {
File(pathFromSftp).mkdirs()
LOG.info("#### Dir is created as defined: '$pathFromSftp' ####")
}
catch (e: Exception) {
LOG.error("Error on create folder - ${e.message}", e)
}

routeHandler {
val userName = systemDefinition.getItem("SFTP_USERNAME")
val password = systemDefinition.getItem("SFTP_PASSWORD")
val pathStrInbound = "${GenesisPaths.runtime()}\\inbound"
val consumerRepo = "${pathStrInbound}\\IDEMPOTENT_CONSUMER.DATA"

from("sftp:localhost:22/training?username=${userName}&password=${password}" +
"&delay=1000&sortBy=file:modified&delete=false&bridgeErrorHandler=true" +
"&useUserKnownHostsFile=false&throwExceptionOnConnectFailed=true&stepwise=false")
.idempotentConsumer(header("CamelFileName"),
FileIdempotentRepository.fileIdempotentRepository(File(consumerRepo), 300000, 15000000))
.log("ALPHA file transfer: \${headers.CamelFileName}")
.to("file:${pathStrInbound}")
}
}

0 comments on commit db06a96

Please sign in to comment.