Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CorrelationEventResequencer |
|
| 2.5;2.5 |
1 | /* | |
2 | * $Id: CorrelationEventResequencer.java 7976 2007-08-21 14:26:13Z dirk.olmes $ | |
3 | * -------------------------------------------------------------------------------------- | |
4 | * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com | |
5 | * | |
6 | * The software in this package is published under the terms of the CPAL v1.0 | |
7 | * license, a copy of which has been included with this distribution in the | |
8 | * LICENSE.txt file. | |
9 | */ | |
10 | ||
11 | package org.mule.routing.inbound; | |
12 | ||
13 | import org.mule.umo.UMOEvent; | |
14 | ||
15 | ||
16 | /** | |
17 | * <code>CorrelationEventResequencer</code> is used to resequence events according | |
18 | * to their dispatch sequence in the correlation group. When the MessageSplitter | |
19 | * router splits an event it assigns a correlation sequence to the individual message | |
20 | * parts so that another router such as the <i>CorrelationEventResequencer</i> can | |
21 | * receive the parts and reorder or merge them. | |
22 | */ | |
23 | public class CorrelationEventResequencer extends AbstractEventResequencer | |
24 | { | |
25 | ||
26 | public CorrelationEventResequencer() | |
27 | { | |
28 | 0 | super(); |
29 | 0 | this.setComparator(new CorrelationSequenceComparator()); |
30 | 0 | } |
31 | ||
32 | protected boolean shouldResequenceEvents(EventGroup events) | |
33 | { | |
34 | 0 | UMOEvent event = (UMOEvent) events.iterator().next(); |
35 | ||
36 | 0 | if (event == null) |
37 | { | |
38 | // nothing to resequence | |
39 | 0 | return false; |
40 | } | |
41 | ||
42 | 0 | int size = event.getMessage().getCorrelationGroupSize(); |
43 | 0 | if (size == -1) |
44 | { | |
45 | 0 | logger.warn("Correlation Group Size not set, but CorrelationResequencer is being used. This can cause messages to be held indefinitely"); |
46 | } | |
47 | ||
48 | 0 | return size == events.size(); |
49 | } | |
50 | ||
51 | } |