on 11-08-2018 2:20 PM
Dear CPI and Groovy experts.
I have a requiremend to delete “heavy” attachments from the payload before passing it to Cloud For Customer.
The sample payload looks as follow (see payload.png).
It has 3 document nodes containing encoded attachments.
In real situations documents can be very big (up to 70 MB) and C4C of course cannot accept them.
Moreover CPI setting limit of 40MB for body size.
The agreed solution is to delete documents one by one and check body size after every iteration of loop.
I’ve created a script in Groovy, which is checking the original Message size.
If it is higher than 40 MB it is doing loop against Document segment and deleting them one by one unless Message size is less than 40 MB or unless there is no more Documents to delete.
The code is failing on line 29 with the following exception:
javax.script.ScriptException: java.lang.Exception: org.apache.camel.TypeConversionException: Error during type conversion from type: java.lang.String to the required type: java.lang.String with value [Body is not logged] due javax.xml.transform.TransformerException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.@ line 29 in script6.groovy, cause: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.
See code attached as an image (groovy.png).
The error is telling that i am not using correct Type, but at the same time it should be String.
I am not competent enough in Java to understand where is the issue. Can you please advice how to solve it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi olegs.veliks,
Hope you are doing well!
I have similar request in project. Could please tell me how did you resolve the issue ?
Regards,
Pavan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you please try this
message.getBody(java.lang.String).getBytes().length
-Bhargav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.