1
votes

i want add some extra information on incomming Pojo, i have used message enricher in mule and do that, here is my full flow. I am using subflow to get the payload and select some values in DB and set that value in same pojo and returning, while in target i am setting as payload but i am getting error like this "An Expression Enricher for "payload" is not registered with Mule."

here is mu flow

<enricher doc:name="Message Enricher">
        <core:flow-ref name="flows1Flow1" doc:name="Flow Reference"/>
        <enrich source="#[groovy:payload]" target="#[payload]"/>            

<logger message="AFTER Enrich: #[payload]" level="INFO" doc:name="Logger"/>
    <component class="com.enrich.AfterEnricher" doc:name="Java"/>


 <sub-flow name="flows1Flow1" doc:name="flows1Flow1">
    <component class="com.enrich.MessageEnrichPattern" doc:name="Java"/>
    <jdbc:outbound-endpoint exchange-pattern="request-response" queryKey="selectData" connector-ref="jdbcConnector" doc:name="Database (JDBC)">
        <jdbc:query key="selectData" value="SELECT Username, Password, ModuleId from Credentials where ModuleId=#[map-payload:moduleId]"/>
    </jdbc:outbound-endpoint>
    <logger message="#[payload]" level="INFO" doc:name="Logger"/>
    <component class="com.enrich.ReceiveMessageEnrichPattern" doc:name="Java"/>
</sub-flow>

here ReceiveMessageEnrichPattern returing

Credential credential = new Credential();
    credential.setUname(hashMap.get("USERNAME").toString());
    credential.setPwd(hashMap.get("PPPP").toString());
    credential.setMid(hashMap.get("MODULEID").toString());
    return credential;

but in after enrich component i am getting exception. Please help me how can enrich my incoming pojo with extra info can add.

1

1 Answers

2
votes

According to the docs, Mule currently only supports two targets for enrichment:

  • flow variables,
  • message headers.

To achieve your goal you need to:

  • store the enricher result (Credential object) in a flow variable,
  • use a custom transformer to copy the values from the Credential object found in the flow variable to the POJO payload in your main flow.