Skip to content

Commit

Permalink
fix: Do not start unneded camel routes (#277)
Browse files Browse the repository at this point in the history
Signed-off-by: carlosthe19916 <2582866+carlosthe19916@users.noreply.github.com>
  • Loading branch information
carlosthe19916 authored May 13, 2023
1 parent 9271c74 commit c28cc4f
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 613 deletions.
606 changes: 0 additions & 606 deletions aa.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public class DocumentRoute extends RouteBuilder {
@ConfigProperty(name = "openubl.storage.type")
String storageType;

@ConfigProperty(name = "openubl.messaging.type")
String schedulerType;
@ConfigProperty(name = "openubl.messaging.jsm.queue")
String jmsQueue;

@ConfigProperty(name = "openubl.messaging.sqs.queue")
String sqsQueue;
Expand Down Expand Up @@ -273,7 +273,7 @@ public void configure() throws Exception {
.to("seda:send-xml?waitForTaskToComplete=Never")
.endChoice()
.when(simple("{{openubl.messaging.type}}").isEqualToIgnoreCase("jms"))
.to(ExchangePattern.InOnly, "jms:queue:send-xml?connectionFactory=#connectionFactory")
.to(ExchangePattern.InOnly, "jms:queue:" + jmsQueue + "?connectionFactory=#connectionFactory")
.endChoice()
.when(simple("{{openubl.messaging.type}}").isEqualToIgnoreCase("sqs"))
.toD("aws2-sqs://" + sqsQueue + "?amazonSQSClient=#amazonSQSClient&autoCreateQueue=true")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@
@ApplicationScoped
public class FilesystemRoute extends RouteBuilder {

@ConfigProperty(name = "openubl.storage.type")
String storageType;

@ConfigProperty(name = "openubl.storage.filesystem.directory")
String fileSystemFolder;

@Override
public void configure() throws Exception {
from("direct:filesystem-save-file")
.id("filesystem-save-file")
.precondition(String.valueOf(storageType.equalsIgnoreCase("filesystem")))
.choice()
.when(header("shouldZipFile").isEqualTo(true))
.marshal().zipFile()
Expand All @@ -55,6 +59,7 @@ public void configure() throws Exception {

from("direct:filesystem-get-file")
.id("filesystem-get-file")
.precondition(String.valueOf(storageType.equalsIgnoreCase("filesystem")))
.process(exchange -> {
String filename = exchange.getIn().getBody(String.class);
byte[] bytes = Files.readAllBytes(Paths.get(filename));
Expand All @@ -72,10 +77,12 @@ public void configure() throws Exception {

from("direct:filesystem-get-file-link")
.id("filesystem-get-file-link")
.precondition(String.valueOf(storageType.equalsIgnoreCase("filesystem")))
.log(LoggingLevel.WARN, "Filesystem does not support link generation.");

from("direct:filesystem-delete-file")
.id("filesystem-delete-file")
.precondition(String.valueOf(storageType.equalsIgnoreCase("filesystem")))
.process(exchange -> {
String filename = exchange.getIn().getBody(String.class);
Files.delete(Paths.get(filename));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
@ApplicationScoped
public class MinioFilesRoute extends RouteBuilder {

@ConfigProperty(name = "openubl.storage.type")
String storageType;

@ConfigProperty(name = "openubl.storage.minio.bucket")
String s3Bucket;

Expand All @@ -59,6 +62,7 @@ public MinioClient produceS3client() {
public void configure() throws Exception {
from("direct:minio-save-file")
.id("minio-save-file")
.precondition(String.valueOf(storageType.equalsIgnoreCase("minio")))
.choice()
.when(header("shouldZipFile").isEqualTo(true))
.marshal().zipFile()
Expand All @@ -76,6 +80,7 @@ public void configure() throws Exception {

from("direct:minio-get-file")
.id("minio-get-file")
.precondition(String.valueOf(storageType.equalsIgnoreCase("minio")))
.choice()
.when(header("shouldUnzip").isEqualTo(true))
.setHeader(MinioConstants.OBJECT_NAME, simple("${body}"))
Expand All @@ -94,10 +99,12 @@ public void configure() throws Exception {

from("direct:minio-get-file-link")
.id("minio-get-file-link")
.precondition(String.valueOf(storageType.equalsIgnoreCase("minio")))
.log(LoggingLevel.WARN, "Minio does not support link generation.");;

from("direct:minio-delete-file")
.id("minio-delete-file")
.precondition(String.valueOf(storageType.equalsIgnoreCase("minio")))
.setHeader(MinioConstants.OBJECT_NAME, simple("${body}"))
.toD("minio://" + s3Bucket + "?minioClient=#minioClient&operation=deleteObject");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
@ApplicationScoped
public class S3FilesRoute extends RouteBuilder {

@ConfigProperty(name = "openubl.storage.type")
String storageType;

@ConfigProperty(name = "openubl.storage.link-expiration", defaultValue = "5000")
String linkExpiration;

Expand Down Expand Up @@ -107,6 +110,7 @@ public S3Client produceS3Presigner() {
public void configure() throws Exception {
from("direct:s3-save-file")
.id("s3-save-file")
.precondition(String.valueOf(storageType.equalsIgnoreCase("s3")))
.choice()
.when(header("shouldZipFile").isEqualTo(true))
.marshal().zipFile()
Expand All @@ -124,6 +128,7 @@ public void configure() throws Exception {

from("direct:s3-get-file")
.id("s3-get-file")
.precondition(String.valueOf(storageType.equalsIgnoreCase("s3")))
.choice()
.when(header("shouldUnzip").isEqualTo(true))
.pollEnrich().simple("aws2-s3://" + s3Bucket + "?amazonS3Client=#s3client&deleteAfterRead=false&fileName=${body}")
Expand All @@ -144,12 +149,14 @@ public void configure() throws Exception {

from("direct:s3-get-file-link")
.id("s3-get-file-link")
.precondition(String.valueOf(storageType.equalsIgnoreCase("s3")))
.setHeader(AWS2S3Constants.KEY, simple("${body}"))
.setHeader(AWS2S3Constants.DOWNLOAD_LINK_EXPIRATION_TIME, constant(linkExpiration))
.toD("aws2-s3://" + s3Bucket + "?amazonS3Client=#s3client&amazonS3Presigner=#s3Presigner&operation=createDownloadLink");

from("direct:s3-delete-file")
.id("s3-delete-file")
.precondition(String.valueOf(storageType.equalsIgnoreCase("s3")))
.setHeader(AWS2S3Constants.KEY, simple("${body}"))
.toD("aws2-s3://" + s3Bucket + "?amazonS3Client=#s3client&operation=deleteObject");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public class JmsMessagesRoute extends RouteBuilder {
@ConfigProperty(name = "openubl.messaging.type")
String schedulerType;

@ConfigProperty(name = "openubl.messaging.jsm.queue")
String jmsQueue;

@Inject
Instance<ConnectionFactory> connectionFactory;

Expand All @@ -46,7 +49,8 @@ public ConnectionFactory connectionFactory() {

@Override
public void configure() throws Exception {
from("jms:queue:send-xml?connectionFactory=#connectionFactory")
from("jms:queue:" + jmsQueue + "?connectionFactory=#connectionFactory")
.id("jms-send-xml")
.precondition(String.valueOf(schedulerType.equalsIgnoreCase("jms")))
.to("direct:send-xml");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class JvmMessagesRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("seda:send-xml")
.id("jvm-send-xml")
.precondition(String.valueOf(schedulerType.equalsIgnoreCase("jvm")))
.to("direct:send-xml");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public SqsClient produceSqsClient() {
@Override
public void configure() throws Exception {
from("aws2-sqs://" + sqsTopic + "?amazonSQSClient=#amazonSQSClient&autoCreateQueue=true")
.id("sqs-send-xml")
.precondition(String.valueOf(schedulerType.equalsIgnoreCase("sqs")))
.to("direct:send-xml");
}
Expand Down
7 changes: 4 additions & 3 deletions application/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ openubl.messaging.sqs.queue=project-openubl
openubl.messaging.sqs.access_key_id=BQA2GEXO711FVBVXDWKM
openubl.messaging.sqs.secret_access_key=uvgz3LCwWM3e400cDkQIH/y1Y4xgU4iV91CwFSPC

openubl.messaging.jsm.host=${quarkus.artemis.host}
openubl.messaging.jsm.username=${quarkus.artemis.username}
openubl.messaging.jsm.password=${quarkus.artemis.password}
quarkus.artemis.host=${openubl.messaging.jsm.host}
quarkus.artemis.username=${openubl.messaging.jsm.username}
quarkus.artemis.password=${openubl.messaging.jsm.password}
openubl.messaging.jsm.queue=project-openubl
%dev.quarkus.artemis.devservices.enabled=false
%test.quarkus.artemis.devservices.enabled=true

Expand Down

0 comments on commit c28cc4f

Please sign in to comment.