[ https://issues.apache.org/activemq/browse/CAMEL-1371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=50553#action_50553 ]
Martin Krasser commented on CAMEL-1371: --------------------------------------- In its current version you can customize gap detection by implementing {{org.apache.camel.processor.resequencer.ExpressionResultComparator}} and set it via the {{comparator()}} DSL element. {code} // Custom gap detection ExpressionResultComparator myComparator = ... // Resequencing route from(...).resequence().stream().comparator(myComparator).to(...); {code} The comparator's relevant methods for gap detection are {{predecessor()}} and {{successor()}}. The {{compare()}} method (from {{java.util.Comparator}}) is needed to order elements in the resequencing queue: {code} public class MyComparator implements ExpressionResultComparator { ... public boolean predecessor(Exchange o1, Exchange o2) { // check if o1 is predecessor of o2 ... } public boolean successor(Exchange o1, Exchange o2) { // check if o1 is sucessor of o2 ... } public int compare(Exchange o1, Exchange o2) { // compare o1 to o2 ... } ... } {code} I see however that there are easier ways for implementing custom gap detection than implementing {{ExpressionResultComparator}} and like the idea to provide something more high-level as described by this issue. I can provide a patch if you want. At the moment, I'm not sure if a Camel {{Predicate}} or {{Expression}} is suitable for implementing custom gap detections. Do you mind if the interface for gap detection is resequencer-specific? > Resequencer - stream - add predicate to allow me to supply my own gap > detection > ------------------------------------------------------------------------------- > > Key: CAMEL-1371 > URL: https://issues.apache.org/activemq/browse/CAMEL-1371 > Project: Apache Camel > Issue Type: New Feature > Components: camel-core > Reporter: Claus Ibsen > Fix For: Future > > > The resequencer stream based uses Long for gap detection as Camel then knows > if there is a gap if eg a number in between is missing. > However sometimes you can not convert/compute a Long that is in sequence > based on your needs. > Imagine you consume files from a folder and want them to be resequenced so > you process them in the correct order. > The file names have this pattern: YYYYMMDD-DNNN.txt. Where YYYYMMDD is the > date pattern and D is a fixed string and NNN is a numeric value for that > particular day. > Eg: 20090223-D001.txt, 20090223-D002.txt ... > So if we could add a predicate to the resequencer where I could impl. the gap > detection, then I would be able to do: > {code} > from("file://inbox").resequence(header("CamelFileName")).gapPredicate(new > MyGapPredicate()).timeout(60000).to("bean:processFileInSequence"); > {code} > Where *gapPredicate* is the new feature. Think about a better name for it, > than gap predicate!! -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.