Professional Documents
Culture Documents
html
TUTORIALS JAVA ANDROID DESIGN PATTERNS SPRING HIBERNATE CAMEL MULE WEB DATA STRUCTURES
Mule enricher as the name suggests helps use to enrich the existing message. For example, we can enrich
the payload, or add new headers, attachments to the current message or call out to another processor and
assign the result to a ow variable without overwriting the existing payload. We can de ne the part that we
are enriching in the attribute target .
Win with the leaders. Find AppExchange solutions that extend Salesforce
to every department and industry.
Salesforce AppExchange
In the below <enricher> element we initialize the outbound property header1 to payload speci ed using
attribute source . We further transform the message using <append-string-transformer> .
We can enrich the message multiple times using child enricher elements each of which has its own target
attribute.
1 <enricher> ?
2 <append-string-transformer message=" and more " />
3 <enrich target="#[header:OUTBOUND:header1]" />
4 <enrich target="#[header:OUTBOUND:header2]" source="#[payload]" />
5 </enricher>
The enricher can call out to another processor or ow. In the below example, we call a di erent ow using flow-
ref , the result returned by the ow is assigned to a ow variable thus the existing payload is not overwritten.
Learn more
http://www.javarticles.com/2018/07/mule-enricher-example.html 1/4
9/1/2018 Mule Enricher Example - http://www.javarticles.com/2018/07/mule-enricher-example.html
1 <enricher target="#[variable:status]"> ?
2 <flow-ref name="determineStatus" />
3 </enricher>
4 <custom-processor class="com.javarticles.mule.MyProcessor"/>
5
6 <sub-flow name="determineStatus">
7 <expression-transformer expression="Processed #[payload]" evaluator="string" />
8 </sub-flow>
MORE POSTS
1 package com.javarticles.mule; ?
File Persistence of B-Tree Index
2
3 import org.mule.api.MuleEvent;
4 import org.mule.api.MuleException;
Guava Multiset Examples
5 import org.mule.api.processor.MessageProcessor;
6
7 public class MyProcessor implements MessageProcessor {
8 Android Nine Patch Drawable Example
9 @Override
10 public MuleEvent process(MuleEvent event) throws MuleException {
11 Object enrichedContent = event.getMessage().getInvocationProperty("status"); Mule accessing cookies example
12 System.out.println("Flow variable(status)=" + enrichedContent);
13 return event;
14 } Java Encapsulation
15
16 }
Android App Development – Skip Welcome Page
http://www.javarticles.com/2018/07/mule-enricher-example.html 2/4
9/1/2018 Mule Enricher Example - http://www.javarticles.com/2018/07/mule-enricher-example.html
Java Find All Active Threads
We send messages to each of the ows and verify the message properties.
MuleEnricherExample:
1 package com.javarticles.mule; ?
2
3 import org.mule.api.MuleContext;
4 import org.mule.api.MuleMessage;
5 import org.mule.api.client.MuleClient;
6 import org.mule.api.context.MuleContextBuilder;
7 import org.mule.api.context.MuleContextFactory;
8 import org.mule.config.DefaultMuleConfiguration;
9 import org.mule.config.spring.SpringXmlConfigurationBuilder;
10 import org.mule.context.DefaultMuleContextBuilder;
11 import org.mule.context.DefaultMuleContextFactory;
12
13 public class MuleEnricherExample {
14 public static void main(String[] args) throws Exception {
15 DefaultMuleConfiguration dmc = new DefaultMuleConfiguration();
16 dmc.setId("muleexample");
17 dmc.setWorkingDirectory("/esb/mule");
18 SpringXmlConfigurationBuilder configBuilder = new SpringXmlConfigurationBuilder(
19 "muleContext.xml");
20 MuleContextBuilder contextBuilder = new DefaultMuleContextBuilder();
21 contextBuilder.setMuleConfiguration(dmc);
22 MuleContextFactory contextFactory = new DefaultMuleContextFactory();
23 MuleContext ctx = contextFactory.createMuleContext(configBuilder,
24 contextBuilder);
25 ctx.start();
26 try {
27 System.out.println("Test enrich1-in flow");
28 MuleClient muleClient = ctx.getClient();
29 MuleMessage response = muleClient.send("vm://enrich1-in", "XYZ", null);
30 System.out.println("Header1: " + response.getInboundProperty("header1"));
31
32 System.out.println("Test enrich2-in flow");
33 response = muleClient.send("vm://enrich2-in", "XYZ", null);
34 System.out.println("Header1: " + response.getInboundProperty("header1"));
http://www.javarticles.com/2018/07/mule-enricher-example.html 3/4
9/1/2018 Mule Enricher Example - http://www.javarticles.com/2018/07/mule-enricher-example.html
35 System.out.println("Header2: " + response.getInboundProperty("header2"));
36
37 System.out.println("Test enrich3-in flow");
38 response = muleClient.send("vm://enrich3-in", "XYZ", null);
39 } finally {
40 ctx.dispose();
41 }
42 }
43 }
Output:
SHARE.
http://www.javarticles.com/2018/07/mule-enricher-example.html 4/4