1 10 11 package org.mule.routing.inbound; 12 13 import org.mule.umo.UMOEvent; 14 15 import java.util.Comparator ; 16 17 27 public class CorrelationEventResequencer extends AbstractEventResequencer 28 { 29 public CorrelationEventResequencer() 30 { 31 setComparator(new CorrelationSequenceComparator()); 32 } 33 34 protected boolean shouldResequence(EventGroup events) 35 { 36 UMOEvent event = (UMOEvent)events.iterator().next(); 37 int size = event.getMessage().getCorrelationGroupSize(); 38 if (size == -1) 39 { 40 logger.warn("Correlation Group Size not set, but CorrelationResequencer is being used. This can cause messages to be held indefinitely"); 41 } 42 return size == events.size(); 43 } 44 45 private class CorrelationSequenceComparator implements Comparator 46 { 47 public int compare(Object o1, Object o2) 48 { 49 int val1 = ((UMOEvent)o1).getMessage().getCorrelationSequence(); 50 int val2 = ((UMOEvent)o2).getMessage().getCorrelationSequence(); 51 if (val1 == val2) 52 { 53 return 0; 54 } 55 else if (val1 > val2) 56 { 57 return 1; 58 } 59 else 60 { 61 return -1; 62 } 63 } 64 } 65 } 66 | Popular Tags |