org.apache.camel.builder
Class FromBuilder

java.lang.Object
  extended by org.apache.camel.builder.BuilderSupport
      extended by org.apache.camel.builder.FromBuilder
All Implemented Interfaces:
ProcessorFactory
Direct Known Subclasses:
AggregatorBuilder, ChoiceBuilder, DelayerBuilder, FilterBuilder, IdempotentConsumerBuilder, MulticastBuilder, PipelineBuilder, ResequencerBuilder, SplitterBuilder, ThrottlerBuilder, ToBuilder

public class FromBuilder
extends BuilderSupport
implements ProcessorFactory

Version:
$Revision: 559613 $

Field Summary
static String DEFAULT_TRACE_CATEGORY
           
 
Constructor Summary
FromBuilder(FromBuilder parent)
           
FromBuilder(RouteBuilder builder, Endpoint from)
           
 
Method Summary
 ProcessorFactory addProcessBuilder(ProcessorFactory processFactory)
           
 void addProcessor(Processor processor)
           
protected  void addProcessorBuilder(Processor processor)
           
 AggregatorBuilder aggregator(Expression correlationExpression)
          A builder for the Aggregator pattern where a batch of messages are processed (up to a maximum amount or until some timeout is reached) and messages for the same correlation key are combined together using some kind of {@link AggregationStrategy ) (by default the latest message is used) to compress many message exchanges into a smaller number of exchanges.
 AggregatorBuilder aggregator(Expression correlationExpression, AggregationStrategy strategy)
          A builder for the Aggregator pattern where a batch of messages are processed (up to a maximum amount or until some timeout is reached) and messages for the same correlation key are combined together using some kind of {@link AggregationStrategy ) (by default the latest message is used) to compress many message exchanges into a smaller number of exchanges.
 ChoiceBuilder choice()
          Creates a choice of one or more predicates with an otherwise clause
 FromBuilder convertBodyTo(Class type)
          Converts the IN message body to the specified type
 FromBuilder convertOutBodyTo(Class type)
          Converts the OUT message body to the specified type
 Processor createProcessor()
           
 Route createRoute()
           
 DelayerBuilder delayer(Expression<Exchange> processAtExpression)
          A builder for the Delayer pattern where an expression is used to calculate the time which the message will be dispatched on
 DelayerBuilder delayer(Expression<Exchange> processAtExpression, long delay)
          A builder for the Delayer pattern where an expression is used to calculate the time which the message will be dispatched on
 DelayerBuilder delayer(long delay)
          A builder for the Delayer pattern where a fixed amount of milliseconds are used to delay processing of a message exchange
 FromBuilder errorHandler(ErrorHandlerBuilder errorHandlerBuilder)
          Installs the given error handler builder
 FilterBuilder filter(Predicate predicate)
          Creates a predicate which is applied and only if it is true then the exchange is forwarded to the destination
 RouteBuilder getBuilder()
           
 Endpoint getFrom()
           
 List<Processor> getProcessors()
           
protected  FromBuilder getRouteBuilder()
           
 IdempotentConsumerBuilder idempotentConsumer(Expression messageIdExpression, MessageIdRepository messageIdRepository)
          Creates an IdempotentConsumer to avoid duplicate messages
 FromBuilder inheritErrorHandler(boolean condition)
          Configures whether or not the error handler is inherited by every processing node (or just the top most one)
 InterceptorBuilder intercept()
           
 FromBuilder intercept(DelegateProcessor interceptor)
           
protected  Processor makeProcessor(ProcessorFactory processFactory)
          Creates the processor and wraps it in any necessary interceptors and error handlers
 ProcessorFactory pipeline(Collection<Endpoint> endpoints)
          Creates a Pipeline of the list of endpoints so that the message will get processed by each endpoint in turn and for request/response the output of one endpoint will be the input of the next endpoint
 ProcessorFactory pipeline(Endpoint... endpoints)
          Creates a Pipeline of the list of endpoints so that the message will get processed by each endpoint in turn and for request/response the output of one endpoint will be the input of the next endpoint
 ProcessorFactory pipeline(String... uris)
          Creates a Pipeline of the list of endpoints so that the message will get processed by each endpoint in turn and for request/response the output of one endpoint will be the input of the next endpoint
 PolicyBuilder policies()
           
 FromBuilder policy(Policy policy)
           
 FromBuilder process(Processor processor)
          Adds the custom processor to this destination which could be a final destination, or could be a transformation in a pipeline
 RecipientListBuilder recipientList(Expression receipients)
          Creates a dynamic Recipient List pattern.
 ResequencerBuilder resequencer(Expression<Exchange>... expressions)
          A builder for the Resequencer pattern where a list of expressions are evaluated to be able to compare the message exchanges to reorder them.
 ResequencerBuilder resequencer(Expression<Exchange> expression)
          A builder for the Resequencer pattern where an expression is evaluated to be able to compare the message exchanges to reorder them.
 ResequencerBuilder resequencer(List<Expression<Exchange>> expressions)
          A builder for the Resequencer pattern where a list of expressions are evaluated to be able to compare the message exchanges to reorder them.
 FromBuilder setBody(Expression expression)
          Adds a processor which sets the body on the IN message
 FromBuilder setHeader(String name, Expression expression)
          Adds a processor which sets the header on the IN message
 FromBuilder setOutBody(Expression expression)
          Adds a processor which sets the body on the OUT message
 FromBuilder setOutHeader(String name, Expression expression)
          Adds a processor which sets the header on the OUT message
 FromBuilder setProperty(String name, Expression expression)
          Adds a processor which sets the exchange property
protected  void setRouteBuilder(FromBuilder routeBuilder)
           
 SplitterBuilder splitter(Expression receipients)
          A builder for the Splitter pattern where an expression is evaluated to iterate through each of the parts of a message and then each part is then send to some endpoint.
 ThrottlerBuilder throttler(long maximumRequestCount)
          A builder for the Delayer pattern where an expression is used to calculate the time which the message will be dispatched on
 ProcessorFactory to(Collection<Endpoint> endpoints)
          Sends the exchange to a list of endpoint using the MulticastProcessor pattern
 ProcessorFactory to(Endpoint... endpoints)
          Sends the exchange to a list of endpoints using the MulticastProcessor pattern
 ProcessorFactory to(Endpoint endpoint)
          Sends the exchange to the given endpoint
 ProcessorFactory to(String... uris)
          Sends the exchange to a list of endpoints using the MulticastProcessor pattern
 ProcessorFactory to(String uri)
          Sends the exchange to the given endpoint URI
 FromBuilder trace()
          Trace logs the exchange before it goes to the next processing step using the DEFAULT_TRACE_CATEGORY logging category.
 FromBuilder trace(String category)
          Trace logs the exchange before it goes to the next processing step using the specified logging category.
protected  Processor wrapInErrorHandler(Processor processor)
          A strategy method to allow newly created processors to be wrapped in an error handler.
protected  Processor wrapProcessor(Processor processor)
          A strategy method which allows derived classes to wrap the child processor in some kind of interceptor such as a filter for the IdempotentConsumerBuilder.
 
Methods inherited from class org.apache.camel.builder.BuilderSupport
body, bodyAs, createErrorHandlerBuilder, deadLetterChannel, deadLetterChannel, deadLetterChannel, endpoint, endpoints, endpoints, getContext, getErrorHandlerBuilder, header, isInheritErrorHandler, loggingErrorHandler, loggingErrorHandler, loggingErrorHandler, loggingErrorHandler, noErrorHandler, outBody, outBody, setContext, setErrorHandlerBuilder, setInheritErrorHandler, systemProperty, systemProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TRACE_CATEGORY

public static final String DEFAULT_TRACE_CATEGORY
See Also:
Constant Field Values
Constructor Detail

FromBuilder

public FromBuilder(RouteBuilder builder,
                   Endpoint from)

FromBuilder

public FromBuilder(FromBuilder parent)
Method Detail

to

public ProcessorFactory to(String uri)
Sends the exchange to the given endpoint URI


to

public ProcessorFactory to(Endpoint endpoint)
Sends the exchange to the given endpoint


to

public ProcessorFactory to(String... uris)
Sends the exchange to a list of endpoints using the MulticastProcessor pattern


to

public ProcessorFactory to(Endpoint... endpoints)
Sends the exchange to a list of endpoints using the MulticastProcessor pattern


to

public ProcessorFactory to(Collection<Endpoint> endpoints)
Sends the exchange to a list of endpoint using the MulticastProcessor pattern


pipeline

public ProcessorFactory pipeline(String... uris)
Creates a Pipeline of the list of endpoints so that the message will get processed by each endpoint in turn and for request/response the output of one endpoint will be the input of the next endpoint


pipeline

public ProcessorFactory pipeline(Endpoint... endpoints)
Creates a Pipeline of the list of endpoints so that the message will get processed by each endpoint in turn and for request/response the output of one endpoint will be the input of the next endpoint


pipeline

public ProcessorFactory pipeline(Collection<Endpoint> endpoints)
Creates a Pipeline of the list of endpoints so that the message will get processed by each endpoint in turn and for request/response the output of one endpoint will be the input of the next endpoint


idempotentConsumer

public IdempotentConsumerBuilder idempotentConsumer(Expression messageIdExpression,
                                                    MessageIdRepository messageIdRepository)
Creates an IdempotentConsumer to avoid duplicate messages


filter

public FilterBuilder filter(Predicate predicate)
Creates a predicate which is applied and only if it is true then the exchange is forwarded to the destination

Returns:
the builder for a predicate

choice

public ChoiceBuilder choice()
Creates a choice of one or more predicates with an otherwise clause

Returns:
the builder for a choice expression

recipientList

public RecipientListBuilder recipientList(Expression receipients)
Creates a dynamic Recipient List pattern.

Parameters:
receipients - is the builder of the expression used in the RecipientList to decide the destinations

splitter

public SplitterBuilder splitter(Expression receipients)
A builder for the Splitter pattern where an expression is evaluated to iterate through each of the parts of a message and then each part is then send to some endpoint.

Parameters:
receipients - the expression on which to split
Returns:
the builder

resequencer

public ResequencerBuilder resequencer(Expression<Exchange> expression)
A builder for the Resequencer pattern where an expression is evaluated to be able to compare the message exchanges to reorder them. e.g. you may wish to sort by some header

Parameters:
expression - the expression on which to compare messages in order
Returns:
the builder

resequencer

public ResequencerBuilder resequencer(List<Expression<Exchange>> expressions)
A builder for the Resequencer pattern where a list of expressions are evaluated to be able to compare the message exchanges to reorder them. e.g. you may wish to sort by some headers

Parameters:
expressions - the expressions on which to compare messages in order
Returns:
the builder

resequencer

public ResequencerBuilder resequencer(Expression<Exchange>... expressions)
A builder for the Resequencer pattern where a list of expressions are evaluated to be able to compare the message exchanges to reorder them. e.g. you may wish to sort by some headers

Parameters:
expressions - the expressions on which to compare messages in order
Returns:
the builder

aggregator

public AggregatorBuilder aggregator(Expression correlationExpression)
A builder for the Aggregator pattern where a batch of messages are processed (up to a maximum amount or until some timeout is reached) and messages for the same correlation key are combined together using some kind of {@link AggregationStrategy ) (by default the latest message is used) to compress many message exchanges into a smaller number of exchanges.

A good example of this is stock market data; you may be receiving 30,000 messages/second and you may want to throttle it right down so that multiple messages for the same stock are combined (or just the latest message is used and older prices are discarded). Another idea is to combine line item messages together into a single invoice message.

Parameters:
correlationExpression - the expression used to calculate the correlation key. For a JMS message this could be the expression header("JMSDestination") or header("JMSCorrelationID")

aggregator

public AggregatorBuilder aggregator(Expression correlationExpression,
                                    AggregationStrategy strategy)
A builder for the Aggregator pattern where a batch of messages are processed (up to a maximum amount or until some timeout is reached) and messages for the same correlation key are combined together using some kind of {@link AggregationStrategy ) (by default the latest message is used) to compress many message exchanges into a smaller number of exchanges.

A good example of this is stock market data; you may be receiving 30,000 messages/second and you may want to throttle it right down so that multiple messages for the same stock are combined (or just the latest message is used and older prices are discarded). Another idea is to combine line item messages together into a single invoice message.

Parameters:
correlationExpression - the expression used to calculate the correlation key. For a JMS message this could be the expression header("JMSDestination") or header("JMSCorrelationID")

delayer

public DelayerBuilder delayer(Expression<Exchange> processAtExpression)
A builder for the Delayer pattern where an expression is used to calculate the time which the message will be dispatched on

Parameters:
processAtExpression - an expression to calculate the time at which the messages should be processed
Returns:
the builder

delayer

public DelayerBuilder delayer(Expression<Exchange> processAtExpression,
                              long delay)
A builder for the Delayer pattern where an expression is used to calculate the time which the message will be dispatched on

Parameters:
processAtExpression - an expression to calculate the time at which the messages should be processed
delay - the delay in milliseconds which is added to the processAtExpression to determine the time the message should be processed
Returns:
the builder

delayer

public DelayerBuilder delayer(long delay)
A builder for the Delayer pattern where a fixed amount of milliseconds are used to delay processing of a message exchange

Parameters:
delay - the default delay in milliseconds
Returns:
the builder

throttler

public ThrottlerBuilder throttler(long maximumRequestCount)
A builder for the Delayer pattern where an expression is used to calculate the time which the message will be dispatched on

Parameters:
processAtExpression - an expression to calculate the time at which the messages should be processed
delay - the delay in milliseconds which is added to the processAtExpression to determine the time the message should be processed
Returns:
the builder

errorHandler

public FromBuilder errorHandler(ErrorHandlerBuilder errorHandlerBuilder)
Installs the given error handler builder

Parameters:
errorHandlerBuilder - the error handler to be used by default for all child routes
Returns:
the current builder with the error handler configured

inheritErrorHandler

public FromBuilder inheritErrorHandler(boolean condition)
Configures whether or not the error handler is inherited by every processing node (or just the top most one)

Parameters:
condition - the falg as to whether error handlers should be inherited or not
Returns:
the current builder

intercept

public InterceptorBuilder intercept()

intercept

public FromBuilder intercept(DelegateProcessor interceptor)

trace

public FromBuilder trace()
Trace logs the exchange before it goes to the next processing step using the DEFAULT_TRACE_CATEGORY logging category.

Returns:

trace

public FromBuilder trace(String category)
Trace logs the exchange before it goes to the next processing step using the specified logging category.

Parameters:
category - the logging category trace messages will sent to.
Returns:

policies

public PolicyBuilder policies()

policy

public FromBuilder policy(Policy policy)

process

public FromBuilder process(Processor processor)
Adds the custom processor to this destination which could be a final destination, or could be a transformation in a pipeline


setBody

public FromBuilder setBody(Expression expression)
Adds a processor which sets the body on the IN message


setOutBody

public FromBuilder setOutBody(Expression expression)
Adds a processor which sets the body on the OUT message


setHeader

public FromBuilder setHeader(String name,
                             Expression expression)
Adds a processor which sets the header on the IN message


setOutHeader

public FromBuilder setOutHeader(String name,
                                Expression expression)
Adds a processor which sets the header on the OUT message


setProperty

public FromBuilder setProperty(String name,
                               Expression expression)
Adds a processor which sets the exchange property


convertBodyTo

public FromBuilder convertBodyTo(Class type)
Converts the IN message body to the specified type


convertOutBodyTo

public FromBuilder convertOutBodyTo(Class type)
Converts the OUT message body to the specified type


getBuilder

public RouteBuilder getBuilder()

getFrom

public Endpoint getFrom()

getProcessors

public List<Processor> getProcessors()

addProcessBuilder

public ProcessorFactory addProcessBuilder(ProcessorFactory processFactory)

addProcessorBuilder

protected void addProcessorBuilder(Processor processor)

addProcessor

public void addProcessor(Processor processor)

createRoute

public Route createRoute()
                  throws Exception
Throws:
Exception

createProcessor

public Processor createProcessor()
                          throws Exception
Specified by:
createProcessor in interface ProcessorFactory
Throws:
Exception

makeProcessor

protected Processor makeProcessor(ProcessorFactory processFactory)
                           throws Exception
Creates the processor and wraps it in any necessary interceptors and error handlers

Throws:
Exception

wrapInErrorHandler

protected Processor wrapInErrorHandler(Processor processor)
                                throws Exception
A strategy method to allow newly created processors to be wrapped in an error handler. This feature could be disabled for child builders such as IdempotentConsumerBuilder which will rely on the FromBuilder to perform the error handling to avoid doubly-wrapped processors with 2 nested error handlers

Throws:
Exception

wrapProcessor

protected Processor wrapProcessor(Processor processor)
A strategy method which allows derived classes to wrap the child processor in some kind of interceptor such as a filter for the IdempotentConsumerBuilder.

Parameters:
processor - the processor which can be wrapped
Returns:
the original processor or a new wrapped interceptor

getRouteBuilder

protected FromBuilder getRouteBuilder()

setRouteBuilder

protected void setRouteBuilder(FromBuilder routeBuilder)


Copyright © 2007 Apache Software Foundation. All Rights Reserved.