org.apache.camel.processor
Class StreamResequencer

java.lang.Object
  extended by org.apache.camel.impl.ServiceSupport
      extended by org.apache.camel.processor.DelegateProcessor
          extended by org.apache.camel.processor.StreamResequencer
All Implemented Interfaces:
Processor, Service

public class StreamResequencer
extends DelegateProcessor
implements Processor

A resequencer that re-orders a (continuous) stream of Exchanges. The algorithm implemented by ResequencerEngine is based on the detection of gaps in a message stream rather than on a fixed batch size. Gap detection in combination with timeouts removes the constraint of having to know the number of messages of a sequence (i.e. the batch size) in advance.

Messages must contain a unique sequence number for which a predecessor and a successor is known. For example a message with the sequence number 3 has a predecessor message with the sequence number 2 and a successor message with the sequence number 4. The message sequence 2,3,5 has a gap because the sucessor of 3 is missing. The resequencer therefore has to retain message 5 until message 4 arrives (or a timeout occurs).

Version:
$Revision: 35332 $
Author:
Martin Krasser

Field Summary
 
Fields inherited from class org.apache.camel.processor.DelegateProcessor
processor
 
Constructor Summary
StreamResequencer(Processor processor, SequenceElementComparator<Exchange> comparator, int capacity)
          Creates a new StreamResequencer instance.
 
Method Summary
protected  void doStart()
           
protected  void doStop()
           
 long getTimeout()
           
 void process(Exchange exchange)
          Processes the message exchange
 void setTimeout(long timeout)
           
 String toString()
           
 
Methods inherited from class org.apache.camel.processor.DelegateProcessor
getProcessor, proceed, processNext, setProcessor
 
Methods inherited from class org.apache.camel.impl.ServiceSupport
addChildService, getThreadName, isRunAllowed, isStarted, isStarting, isStopped, isStopping, nextThreadCounter, removeChildService, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StreamResequencer

public StreamResequencer(Processor processor,
                         SequenceElementComparator<Exchange> comparator,
                         int capacity)
Creates a new StreamResequencer instance.

Parameters:
processor - the next processor that processes the re-ordered exchanges.
comparator - a SequenceElementComparator for comparing sequence number contained in Exchanges.
capacity - the capacity of the inbound queue.
Method Detail

doStart

protected void doStart()
                throws Exception
Overrides:
doStart in class DelegateProcessor
Throws:
Exception

doStop

protected void doStop()
               throws Exception
Overrides:
doStop in class DelegateProcessor
Throws:
Exception

process

public void process(Exchange exchange)
             throws Exception
Description copied from interface: Processor
Processes the message exchange

Specified by:
process in interface Processor
Overrides:
process in class DelegateProcessor
Throws:
Exception - if an internal processing error has occurred.

getTimeout

public long getTimeout()

setTimeout

public void setTimeout(long timeout)

toString

public String toString()
Overrides:
toString in class DelegateProcessor


Copyright © 2008 IONA Open Source Community. All Rights Reserved.