Hi
Yes its possible. But you need to use a custom message object to
contain the X number of messages.
And that object must be serializable so you can transfer it over the wire.
public class MyPayload implements Serializable {
private List<Serializable> messages;
.. methods to add/get messages
}
And then in your AggregationStrategy you "merge" all the aggregation
into that MyPayload.
Besides the message payload itself, you may want to add the message
headers as well, in case there is some important data you need to
transfer as well.
Instead of all this then I would suggest to look at how you can tune
your ActiveMQ for better performance.
It has many options for doing that.
Then you can use this aggregation stuff as a kind of last resort.
On Fri, May 6, 2011 at 9:39 AM, dcheckoway <[email protected]> wrote:
> Is it possible to use aggregate and split with ActiveMQ/JMS? What I'm
> interested in doing is a very simple aggregation, the goal being to reduce
> the sheer # of JMS messages that ActiveMQ has to deal with. "Bundling" N
> messages together is likely to speed up the throughput in my particular
> case. My message bodies are byte[] arrays (currently using BytesMessage),
> and they're relatively small (500-2000 bytes). My theory is that I can get
> better JMS throughput if I "bundle" some number of payloads together in an
> aggregated JMS message.
>
> So, assuming that this isn't a horrible idea, the approach would be
> something like this...
>
> Aggregate up to N messages at a time, forcing completion every so often if
> there are any incomplete aggregates, and there's no correlation at all.
> Just group up to N messages together, to be split again on the consumer
> side.
>
> Producer side:
>
> <from uri="..."/>
> <aggregate strategyRef="???" completionSize="3" completionInterval="5000">
> <correlationExpression><constant>true</constant></correlationExpression>
> <to uri="activemq:queue:myAggregatedQueue"/>
> </aggregate>
>
> Consumer side:
>
> <from uri="activemq:queue:myAggregatedQueue"/>
> <split>
> ???
> <bean ref="myPojoConsumer" method="onWhatever"/>
> </split>
>
> I've got the producer side working...sorta. The completionSize and
> completionInterval part of it works great. But...I tried using
> GroupedExchangeAggregationStrategy, and I see that it builds a
> List<Exchange>, but that doesn't seem to work with JMS. The message body
> ends up being null...which I guess makes sense given what
> GroupedExchangeAggregationStrategy does, and given what I believe the JMS
> component does (only uses body?).
>
> So what I'm wondering is...does Camel support what I'm trying to do? I
> could obviously write my own bundling and un-bundling logic, but I was
> hoping to get that out of the box for free, but of course! Wishful
> thinking?
>
> Thanks!
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/aggregate-split-with-JMS-possible-tp4375238p4375238.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Claus Ibsen
-----------------
FuseSource
Email: [email protected]
Web: http://fusesource.com
CamelOne 2011: http://fusesource.com/camelone2011/
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/