public class MessageEnricher extends AbstractMessageProcessorOwner implements Processor
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| Modifier and Type | Class and Description |
|---|---|
static class |
MessageEnricher.EnrichExpressionPair |
ReactiveProcessor.ProcessingTypeflowConstruct, messagingExceptionHandler, muleContext| Constructor and Description |
|---|
MessageEnricher() |
| Modifier and Type | Method and Description |
|---|---|
void |
addEnrichExpressionPair(MessageEnricher.EnrichExpressionPair pair) |
org.reactivestreams.Publisher<Event> |
apply(org.reactivestreams.Publisher<Event> publisher)
Applies a
Publisher function transforming a stream of Event's. |
protected Event |
enrich(Event event,
Event eventToEnrich) |
protected Event |
enrich(Event currentEvent,
Event enrichmentEvent,
String sourceExpressionArg,
String targetExpressionArg,
ExtendedExpressionManager expressionManager) |
protected List<Processor> |
getOwnedMessageProcessors() |
Event |
process(Event event)
Invokes the MessageProcessor.
|
void |
setEnrichExpressionPairs(List<MessageEnricher.EnrichExpressionPair> enrichExpressionPairs) |
void |
setEnrichmentMessageProcessor(Processor enrichmentProcessor) |
void |
setMessageProcessor(Processor enrichmentProcessor)
For spring
|
getOwnedObjectsdispose, getFlowConstruct, getMuleContext, initialise, setFlowConstruct, setMessagingExceptionHandler, setMuleContext, start, stopgetAnnotation, getAnnotations, getLocation, setAnnotationsclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetProcessingTypesetMuleContextsetFlowConstructpublic Event process(Event event) throws org.mule.runtime.api.exception.MuleException
Processorprotected Event enrich(Event currentEvent, Event enrichmentEvent, String sourceExpressionArg, String targetExpressionArg, ExtendedExpressionManager expressionManager)
public org.reactivestreams.Publisher<Event> apply(org.reactivestreams.Publisher<Event> publisher)
ProcessorPublisher function transforming a stream of Event's.
The default implementation delegates to Processor.process(Event) and will:
Processor.process(Event) returns null.protected Event enrich(Event event, Event eventToEnrich) throws org.mule.runtime.api.exception.MuleException
org.mule.runtime.api.exception.MuleExceptionpublic void setEnrichmentMessageProcessor(Processor enrichmentProcessor)
public void setMessageProcessor(Processor enrichmentProcessor)
public void setEnrichExpressionPairs(List<MessageEnricher.EnrichExpressionPair> enrichExpressionPairs)
public void addEnrichExpressionPair(MessageEnricher.EnrichExpressionPair pair)
protected List<Processor> getOwnedMessageProcessors()
getOwnedMessageProcessors in class AbstractMessageProcessorOwnerCopyright © 2003–2017 MuleSoft, Inc.. All rights reserved.