Skip to Content
0

Body length of an HCI message

Jan 18, 2017 at 10:21 AM

220

avatar image

How can I get the body length of an HCI message? In my scenario I have a sender Mail adapter but this question can be also generic.

Basically, I need to route the message if its body length is smaller than a certain value. I tried with the expression ${body.length} (from Apache Camel Simple Expression Language) but it is not accepted in the router.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Davide Serrone Jan 18, 2017 at 01:16 PM
0

I solved through a Groovy script:

message.setHeader("bodyLength", body.length());

and checking the value ${header.bodyLength} in the router condition. But I'm wondering if there is a way without the usage of the script.

Share
10 |10000 characters needed characters left characters exceeded
Sriprasad Shivaram Bhat Jan 18, 2017 at 03:22 PM
0

Hello Davide,

${in.body.length} will give you the desired output.Please follow below about the usage

Add an Content Modifier and store the value in Property like below. In later stage call the Property like ${property.Body_Length}

Regards,

Sriprasad Shivaram Bhat


Share
10 |10000 characters needed characters left characters exceeded
Davide Serrone Jan 20, 2017 at 01:13 PM
0

Hi Sriprasad,

I tried your suggestion but I get:

org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: .length on null due to: org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: length on null due to: org.apache.camel.component.bean.MethodNotFoundException: Method with name: length not found on bean: javax.mail.internet.MimeMultipart@49169724 of type: javax.mail.internet.MimeMultipart. Exchange[][MailMessage@0x508de809], cause: org.apache.camel.component.bean.MethodNotFoundException: Method with name: length not found on bean: javax.mail.internet.MimeMultipart@49169724 of type: javax.mail.internet.MimeMultipart. Exchange[][MailMessage@0x508de809]
Share
10 |10000 characters needed characters left characters exceeded
Sriprasad Shivaram Bhat Jan 20, 2017 at 01:17 PM
0

Hello Davide

Could you please share more details of your Iflow like which step you have before setting this property and in which step you are getting this error,

Regards,

Sriprasad Shivaram Bhat

Share
10 |10000 characters needed characters left characters exceeded