Content Length Metadata Selector (.^contentLength)

Content Length Metadata Selector (.^contentLength)

Returns the content length of the value, if the value is present.

In the following Mule app flow, the Logger uses payload.^contentLength to select the length of the string my string, set 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 class to which “my string” belongs. –>

<logger level=”INFO” doc:name=”Logger” message=”#[payload.^contentLength]”/>

</flow>

The Studio console output shows that the length of the input string (my string) is eleven (9) characters long. The length includes the blank space in the string.

Console Output in Anypoint Studio:

INFO  2019-05-07 16:59:33,690 [[MuleRuntime].cpuLight.07:

[carets].caretsFlow.CPU_LITE @39f1dbde]

[event: 28ce97a0-7124-11e9-acfe-8c8590a99d48]

org.mule.runtime.core.internal.processor.LoggerMessageProcessor:

11

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

Instagram

Facebook

Recent Posts

Find Intersection of Two Singly Linked Lists

You are given two singly linked lists that intersect at some node. Your task is…

4 months ago

Minimum Cost to Paint Houses with K Colors

A builder plans to construct N houses in a row, where each house can be…

4 months ago

Longest Absolute Path in File System Representation

Find the length of the longest absolute path to a file within the abstracted file…

4 months ago

Efficient Order Log Storage

You manage an e-commerce website and need to keep track of the last N order…

5 months ago

Select a Random Element from a Stream

You are given a stream of elements that is too large to fit into memory.…

5 months ago

Estimate π Using Monte Carlo Method

The formula for the area of a circle is given by πr². Use the Monte…

5 months ago