0

Trying a very simple camel route:

from("aws-s3://javatutorial1232boomiau?amazonS3Client=#s3client&deleteAfterRead=true&fileName=My2.jsp").process(Empty2).log(LoggingLevel.INFO, "Replay Message Sent to file:s3out ${in.header.CamelAwsS3Key}")
            .to("stream:out");

I am using verion 2.20.2 (latest as of today). The file is not getting deleted from the bucket. I have done some research and by the looks of it the the exchange passed in to the processCommit method lacks any headers. The headers it is looking for are bucket name and key

String bucketName = exchange.getIn().getHeader(S3Constants.BUCKET_NAME, String.class);
String key = exchange.getIn().getHeader(S3Constants.KEY, String.class);

I've also tried a to("file://Users/user/out.txt") file is also not getting deleted and the headers appear to be those of file component.

EDIT:

I noticed that if I remove the .processor(Empty2) the file is deleted from the bucket. The processor does not do any work:

@Override
public void process(Exchange exchange) throws Exception {

    Object body = exchange.getIn().getBody();
    System.out.println("1: "+body);
    Object body2 = exchange.getOut().getBody();
    System.out.println("2: "+body2);     
}

So why would it work without it but not with a processor? How should I process a message if processor cannot be used?

1 Answers1

1

As Claus pointed out, using exchange.getOut() creates outgoing (empty) message body on the exchange. None of the headers are copied to the exchange and as such they are all lost. When it comes to processCommit the header for bucket name and key have been lost.

So either do not access getOut() or copy all headers from In to Out.