简体   繁体   中英

Apache camel : how to split the file and send to multiple end points

I am new to Apache Camel and using Java DSL. I want to send a image file to different end points by splitting it using image processing tool. What are all the components do I need to use to achieve that and also I need to send the split images to one more end point.

You should take a look at the chapter "Using a Pojo to do the splitting" from http://camel.apache.org/splitter.html

Example for your needs as far as i understood for the pojo:

public List<Message> splitMessage(Exhange exchange) {
    List<Message> answer = new ArrayList<Message>();
    File inputFile = exchange.getIn().getBody(File.class);
    List<YourObject> parts = yourSplittingOfTheFile(inputFile);
    for (YourObject part : parts) {
        DefaultMessage message = new DefaultMessage();
        message.setBody(body);
        answer.add(message);
    }
    return answer;
}

Afterwards you can send each part to one or more endpoints in your split block.

kind regards, soilworker

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM