How to use message enricher
-
Upload
sivachandra-mandalapu -
Category
Education
-
view
94 -
download
1
Transcript of How to use message enricher
How to use Message Enricher
23-05-2015
Abstract
• The main motto of this PPT is How to use Message Enricher in our applications.
Introduction
• A message enricher can be used to lookup the state using the zip code from an enrichment resource. The enricher calls out to the enrichment resource with the current message (containing the zip code) then enriches the current message with the result.
Example
.mflow• <?xml version="1.0" encoding="UTF-8"?>
• <mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
• xmlns:spring="http://www.springframework.org/schema/beans" • xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"• xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-
current.xsd• http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd• http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd• http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">• <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8090" doc:name="HTTP Listener Configuration"/>• <flow name="MessageEnricherFlow">• <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>• <set-variable variableName="test1" value="message from flow" doc:name="Variable"/>• <set-variable variableName="test2" value="Hai" doc:name="Variable"/>• <logger level="INFO" doc:name="Logger" message="Before Message Enricher--Test1:#[flowVars.test1]--Test2:#[flowVars.test2]"/>• <enricher target="#[flowVars.test1]" doc:name="Message Enricher">• <flow-ref name="MessageEnricherFlow1" doc:name="MessageEnricherFlow1">• </flow-ref>• </enricher>• <logger level="INFO" doc:name="Logger" message="After Message Enricher--Test1:#[flowVars.test1]--Test2:#[flowVars.test2]"/>• </flow>• <flow name="MessageEnricherFlow1">• <set-payload value="India" doc:name="Set Payload"/>• </flow>• </mule>
• Output:• INFO 2016-05-23 14:18:39,246 [main] org.mule.module.launcher.MuleDeploymentService: • ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++• + Started app 'MessageEnricher' +• ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++• INFO 2016-05-23 14:18:39,276 [main] org.mule.module.launcher.DeploymentDirectoryWatcher: • ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++• + Mule is up and kicking (every 5000ms) +• ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++• INFO 2016-05-23 14:18:39,370 [main] org.mule.module.launcher.StartupSummaryDeploymentListener: • **********************************************************************• * - - + DOMAIN + - - * - - + STATUS + - - *• **********************************************************************• * default * DEPLOYED *• **********************************************************************
• *******************************************************************************************************• * - - + APPLICATION + - - * - - + DOMAIN + - - * - - + STATUS + - - *• *******************************************************************************************************• * MessageEnricher * default * DEPLOYED *• *******************************************************************************************************
• INFO 2016-05-23 14:19:50,582 [[MessageEnricher].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: Before Message Enricher--Test1:message from flow--Test2:Hai
• INFO 2016-05-23 14:19:50,647 [[MessageEnricher].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: After Message Enricher--Test1:India--Test2:Hai
• Flow of execution:1. URL to trigger the service from browserhttp://localhost:80902. Logger component displays flowVars before Message Enricher and after Message Enricher
References
• https://docs.mulesoft.com/mule-user-guide/v/3.6/message-enricher