MIME Type Metadata Selector (.^mimeType)
Returns the MIME type (without parameters) of a value, for example, application/json, and { “myMimeType” : payload.^mimeType } might return { “myMediaType”: “/” } for an input POJO.
In the following Mule app flow, the Loggers use payload.^mimeType to select a string “my string”, then to select a string that is set within an fx expression (#[“my string as String type” as String]) in the Set Payload (set-payload) component.
Mule App XML in Anypoint Studio:
<flow name=”setpayloadobjectFlow” >
<scheduler doc:name=”Scheduler” >
<scheduling-strategy >
<fixed-frequency frequency=”15″ timeUnit=”SECONDS”/>
</scheduling-strategy>
</scheduler>
<!– Set the payload to “my string”. –>
<set-payload value='”my string”‘ doc:name=”Set Payload” />
<!– Select the MIME type of “my string”. –>
<logger level=”INFO” doc:name=”Logger” message=’#[payload.^mimeType]’/>
<!– Set the payload using the fx expression “my string” as String. –>
<set-payload value=’#[“my string as String type” as String]’ doc:name=”Set Payload” />
<!– Select the MIME type of a Java string. –>
<logger level=”INFO” doc:name=”Logger” message=’#[payload.^mimeType]’/>
</flow>
The Studio console output shows that the simple string has the MIME type /, while the string that is set in the fx expression has the MIME type application/java.
Console Output in Anypoint Studio:
INFO 2019-04-20 17:02:07,762 [[MuleRuntime].cpuLight.06:
[setpayloadobject].setpayloadobjectFlow.CPU_LITE @2d6f64b9]
[event: b4097b00-63c8-11e9-bcff-8c8590a99d48]
org.mule.runtime.core.internal.processor.LoggerMessageProcessor:
*/*
INFO 2019-04-20 17:02:08,029 [[MuleRuntime].cpuLight.06:
[setpayloadobject].setpayloadobjectFlow.CPU_LITE @2d6f64b9]
[event: b4097b00-63c8-11e9-bcff-8c8590a99d48]
org.mule.runtime.core.internal.processor.LoggerMessageProcessor:
application/java
Follow Me
If you like my post please follow me to read my latest post on programming and technology.
Leave a Comment