Usecase: We generate a csv file when user hits an endpoint, which we want to upload to different sources (FTP & S3). We need to encrypt & transform the files before uploading. Here's how the routes look like (oversimplified):
FTP Route:
from("file:temp?include=sample.csv&noop=true")
.routeId("ftpRoute" + LocalDateTime.now())
.marshal().pgp("file:temp/encryptionKey.asc", "someuserid", null, true, true)
.process(new SomeComplexProcessor())
.to("sftp:localhost:22/destinationDir?username=username&password=RAW(password)")
.setHeader(FILE_NAME, "metadata.txt")
.process(new MetadataFileGenerator())
.marshal()
.bindy(BindyType.Csv, MetadataFile.class)
.to("sftp:localhost:22/destinationDir?username=username&password=RAW(password)")
.process(new KillRouteProcessor());
S3 Route:
from("file:temp?include=sample.csv&noop=true")
.routeId("s3Route" + LocalDateTime.now())
.marshal().pgp("file:temp/encryptionKey.asc", "someuserid", null, true, true)
.process(new SomeComplexProcessor())
.to("aws-s3:bucketName?accessKey=ACCESS_KEY&secretKey=RAW(SECRET_KEY)®ion=REGION")
.setHeader(FILE_NAME, "metadata.txt")
.process(new MetadataFileGenerator())
.marshal()
.bindy(BindyType.Csv, MetadataFile.class)
.to("aws-s3:bucketName?accessKey=ACCESS_KEY&secretKey=RAW(SECRET_KEY)®ion=REGION")
.process(new KillRouteProcessor());
What's working: S3 & SFTP upload routes are working correctly.
Requirements:
What I've tried:
Environment:
Camel 3.4.3, Spring Boot 2.2.3, Java8,
I managed to get it working by using a static route id (Removed LocalDateTime.now()). Here's what I learnt while fixing Camel issues.
LocalDateTime.now()
in my route id. I was seeing this error before I changed:Multiple consumers for the same endpoint is not allowed: direct://routeName .....
eg. .enrich("direct:subroute", AggregationStrategies.useOriginal())
.
This will share a copy of parent route's headers to the subroute. It'll help you to avoid some weird issues.
Feel free to comment in case if you'd like to know more.