I am new to mule ESB. I have a requirement to set HTTP headers where the values should be fetched from MySQLDB. I am able to fetch values from DB. DB returned multiple column values with one row.
I can able to set one column value in flow variable(flowVars) and that can be set in HTTP headers. But if i have to set multiple column variables in each HTTP headers will leads me to write multiple set variable command.
How can I avoid to write multiple set variable command ? (Is there any mule expresion to set multiple variable by single command ?) Is there any other simple way to achieve this ?
<flow name="mule_eeFlow">
<http:listener config-ref="HTTP_Input_eba_Listener_Configuration" path="/XXX/additem" doc:name="HTTP"/>
<db:select config-ref="MySQL_Configuration" doc:name="Database">
<db:template-query-ref name="Template_Query"/>
</db:select>
<set-variable variableName="LEVEL" value="#[message.payload[0].'X-API-COMPATIBILITY-LEVEL']" doc:name="Variable"/>
<set-variable variableName="DEVNAME" value="#[message.payload[0].'X-API-DEV-NAME']" doc:name="Variable"/>
<set-variable variableName="APPNAME" value="#[message.payload[0].'X-API-APP-NAME']" doc:name="Variable"/>
<set-variable variableName="CERTNAME" value="#[message.payload[0].'X-API-CERT-NAME']" doc:name="Variable"/>
<set-variable variableName="SITEID" value="#[message.payload[0].'X-API-SITEID']" doc:name="Variable"/>
<set-variable variableName="CALLNAME" value="#[message.payload[0].'X-API-CALL-NAME']" doc:name="Variable"/>
<custom-transformer class="AddingHTTPHeader" doc:name="Java"/>
</flow>
My Java code look like
@Override
public Object transformMessage(MuleMessage message, String outputEncoding)
throws TransformerException {
// TODO Auto-generated method stub
message.setOutboundProperty("X-API-COMPATIBILITY-LEVEL", message.getInvocationProperty("LEVEL"));
message.setOutboundProperty("X-API-DEV-NAME", message.getInvocationProperty("DEVNAME"));
message.setOutboundProperty("X-API-APP-NAME", message.getInvocationProperty("APPNAME"));
message.setOutboundProperty("X-API-CERT-NAME", message.getInvocationProperty("CERTNAME"));
message.setOutboundProperty("X-API-SITEID", message.getInvocationProperty("SITEID"));
message.setOutboundProperty("X-API-CALL-NAME", message.getInvocationProperty("CALLNAME"));
return null;
}