Hi Yeah as people have said here. I think its hard to implement an expression/logic in camel-core, that supports all kinds of messages bodies/headers/properties/attachments and whatnot that is possible out there.
Also it gets trickier when you work with streams, as you would need to access the total stream to get its size, and then you would not be able to re-read the stream again, unless you use Camel's stream caching. Though if using stream caching you have the message body size out of the box with: org.apache.camel.StreamCache#length For other kinds like String its easier. But what about JSon or XML if they are represented as org.w3c.Document, or as a Map in json etc. For XML as DOM would you likely need to marshal it as byte[] / String as XML and then count its length etc. And for JSon not sure if you would need to do the same etc. Doing that adds overhead. And for POJOs how do you count their size? Or does it matter? And what if the POJO is not serializable. ? On Sun, Nov 24, 2013 at 1:09 AM, Hadrian Zbarcea <[email protected]> wrote: > So that's one way of doing it. I assume you'd want that customized to > include headers or not, right? > > Now how's that different than having an expression (actually any number of > specialized expressions), returning the size calculated using your algorithm > of choice. Set your header of choice with the value and use it in other > expressions for processing (content based routing may be a typical case). > > My $0.02, > Hadrian > > > > > On 11/23/2013 03:20 PM, Jan Matèrne (jhm) wrote: >> >> Store the object in a byte array and count the bytes? >> >> Jan >> >>> -----Ursprüngliche Nachricht----- >>> Von: Hadrian Zbarcea [mailto:[email protected]] >>> Gesendet: Samstag, 23. November 2013 20:00 >>> An: [email protected] >>> Betreff: Re: [Feature Enhancement] Camel body size >>> >>> I wonder how you'd implement that in the general case. A pojo, array of >>> pojos, do you include the size of the headers, are headers pojos, >>> arrays of pojos... What about properties... >>> >>> Hadrian >>> >>> >>> On 11/22/2013 03:57 PM, Matt Pavlovich wrote: >>>> >>>> Hello- >>>> >>>> I opened a ticket to request adding a feature for components to >>> >>> provide a Body size to the Exchange that could be used by Simple, or >>> set as a header. >>>> >>>> >>>> https://issues.apache.org/jira/browse/CAMEL-6984 >>>> >>>> I see it solving a couple things: >>>> >>>> 1. Provide throughput metrics >>>> 2. Route based on message sizing >>>> >>>> What does the community think about this? Any suggestions on >>> >>> improvements/features or implementation approaches? >>>> >>>> >>>> Thanks, >>>> Matt Pavlovich >>>> >> > -- Claus Ibsen ----------------- Red Hat, Inc. Email: [email protected] Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen
