org.mule.enricher
Class MessageEnricher

java.lang.Object
  extended by org.mule.processor.AbstractMuleObjectOwner<MessageProcessor>
      extended by org.mule.processor.AbstractMessageProcessorOwner
          extended by org.mule.enricher.MessageEnricher
All Implemented Interfaces:
AnnotatedObject, FlowConstructAware, MuleContextAware, Disposable, Initialisable, Lifecycle, Startable, Stoppable, MessageProcessor

public class MessageEnricher
extends AbstractMessageProcessorOwner
implements MessageProcessor

The Message Enricher allows the current message to be augmented using data from a seperate resource.

The Mule implementation the Enrichment Resource can be any Message Processor. This allows you to not only use a JDBC endpoint directly but also call out to a remote service via HTTP or even reference another flow or sub-flow.

The Message Processor that implements the Enrichment Resource is invoked with a copy of the current message along with any flow or session variables that are present. Invocation of the this message processor is done in a separate context to the main flow such that any modification to the message (and it's properties and attachments) or flow or session variables will not be reflected in the flow where the enricher is configured.

The Enrichment Resource should always return a result. If it doesn't then the Enricher will simply leave the message untouched.

The way in which the message is enriched (or modified) is by explicitly configuring mappings (source -> target) between the result from the Enrichment Resource and the message using of Mule Expressions. Mule Expressions are used to both select the value to be extracted from result that comes back from the enrichment resource (source) and to define where this value to be inserted into the message (target). The default 'source' if it's not configured is the payload of the result from the enrichment resource..

EIP Reference: http://eaipatterns.com/DataEnricher.html


Nested Class Summary
static class MessageEnricher.EnrichExpressionPair
           
 
Field Summary
 
Fields inherited from class org.mule.processor.AbstractMuleObjectOwner
flowConstruct, muleContext
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Startable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Stoppable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Fields inherited from interface org.mule.api.AnnotatedObject
PROPERTY_NAME
 
Constructor Summary
MessageEnricher()
           
 
Method Summary
 void addEnrichExpressionPair(MessageEnricher.EnrichExpressionPair pair)
           
protected  void enrich(MuleMessage currentMessage, MuleMessage enrichmentMessage, String sourceExpressionArg, String targetExpressionArg, ExpressionManager expressionManager)
           
protected  List<MessageProcessor> getOwnedMessageProcessors()
           
 MuleEvent process(MuleEvent event)
          Invokes the MessageProcessor.
 void setEnrichExpressionPairs(List<MessageEnricher.EnrichExpressionPair> enrichExpressionPairs)
           
 void setEnrichmentMessageProcessor(MessageProcessor enrichmentProcessor)
           
 void setMessageProcessor(MessageProcessor enrichmentProcessor)
          For spring
 
Methods inherited from class org.mule.processor.AbstractMessageProcessorOwner
getAnnotation, getAnnotations, getOwnedObjects, setAnnotations
 
Methods inherited from class org.mule.processor.AbstractMuleObjectOwner
dispose, getFlowConstruct, getMuleContext, initialise, setFlowConstruct, setMuleContext, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mule.api.lifecycle.Initialisable
initialise
 
Methods inherited from interface org.mule.api.lifecycle.Startable
start
 
Methods inherited from interface org.mule.api.lifecycle.Stoppable
stop
 
Methods inherited from interface org.mule.api.lifecycle.Disposable
dispose
 
Methods inherited from interface org.mule.api.context.MuleContextAware
setMuleContext
 
Methods inherited from interface org.mule.api.construct.FlowConstructAware
setFlowConstruct
 

Constructor Detail

MessageEnricher

public MessageEnricher()
Method Detail

process

public MuleEvent process(MuleEvent event)
                  throws MuleException
Description copied from interface: MessageProcessor
Invokes the MessageProcessor.

Specified by:
process in interface MessageProcessor
Parameters:
event - MuleEvent to be processed
Returns:
optional response MuleEvent
Throws:
MuleException

enrich

protected void enrich(MuleMessage currentMessage,
                      MuleMessage enrichmentMessage,
                      String sourceExpressionArg,
                      String targetExpressionArg,
                      ExpressionManager expressionManager)

setEnrichmentMessageProcessor

public void setEnrichmentMessageProcessor(MessageProcessor enrichmentProcessor)

setMessageProcessor

public void setMessageProcessor(MessageProcessor enrichmentProcessor)
For spring


setEnrichExpressionPairs

public void setEnrichExpressionPairs(List<MessageEnricher.EnrichExpressionPair> enrichExpressionPairs)

addEnrichExpressionPair

public void addEnrichExpressionPair(MessageEnricher.EnrichExpressionPair pair)

getOwnedMessageProcessors

protected List<MessageProcessor> getOwnedMessageProcessors()
Specified by:
getOwnedMessageProcessors in class AbstractMessageProcessorOwner


Copyright © 2003-2012 MuleSoft, Inc.. All Rights Reserved.