I am trying to send the files from SFTP server to S3 Bucket. I wrote a spring-boot application using apache camel and it works perfectly fine for one node. I want to scale my application to multiple nodes. To avoid processing same file by multiple nodes, i am using HazelcastIdempotentRepository
using this tutorial.
from(source)
.pollEnrich(source)
.log("Uploading file ${file:name} started...")
.setHeader(S3Constants.CONTENT_LENGTH, simple("${in.header.CamelFileLength}"))
.setHeader(S3Constants.KEY, simple("${in.header.CamelFileNameOnly}"))
.toF("hazelcast:%sfoo", HazelcastConstants.SEDA_PREFIX);
fromF("hazelcast:%sfoo", HazelcastConstants.SEDA_PREFIX)
.idempotentConsumer(simple("*"), hazelcastIdempotentRepo)
.setHeader(HazelcastConstants.OBJECT_ID, simple("${exchangeId}"))
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PUT_OPERATION))
//.setHeader(S3Constants.CONTENT_LENGTH, simple("${in.header.CamelAwsS3ContentLength}"))
.setHeader(S3Constants.KEY, header(S3Constants.KEY)) // How to get file name here ??
.toF(destination)
.log("Uploading file ${file:name} completed...");
I am getting the following exception
java.lang.IllegalArgumentException: AWS S3 Key header missing.
This works when i am polling on SFTP Endpoint.
.setHeader(S3Constants.KEY, simple("${in.header.CamelFileNameOnly}"))
If i hardcode the filename as below, it works as expected.
.setHeader(S3Constants.KEY, constant("test.txt"))
How do i get fileName header from Hazelcast Queue?