Robert Thullner wrote:
> 
> Thans Przemek for the quick reply, however this code always takes the last
> splitted message, but does not aggregate all messages
> 

Sorry for not being precise. Probably the default strategy is
UseLatestAggregationStrategy:

public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
        return newExchange;
    }

so it may work as you observed.


Robert Thullner wrote:
> 
> I combined your Expression with an AggregationStrategy. It seems to work
> this way, but I must say, that I do not know why it works. My code for the
> aggregation now looks like this. My messages are all text messages, so I
> simply concatenates the strings of the message
> 
> AggregationStrategy aggregationStrategy = new AggregationStrategy() {
>       public Exchange aggregate(Exchange oldExchange, Exchange
> newExchange) {
>       String oldBody = (String)oldExchange.getIn().getBody();
>       String newBody = (String)newExchange.getIn().getBody();
>                         
>       String aggMessage = oldBody+newBody;
>       newExchange.getIn().setBody(aggMessage);
>       return newExchange;
>      }
> }; 
> 
> Expression aggregatorExpression = new Expression(){
>       public Object evaluate(Exchange exchange) {
>               JmsMessage in = (JmsMessage) exchange.getIn();
>             String jmsCorrelationID = null;
>             try {
>               jmsCorrelationID = in.getJmsMessage().getJMSCorrelationID();
>                   System.out.println("corID: " + jmsCorrelationID);
>             } catch (JMSException e) {
>                       throw new RuntimeException(e);
>             }
>             return jmsCorrelationID;
>             }
>  }; 
>                 
>                                
>  //aggregate parts to one message
>  from("hospital:camel.hospital.nurse.send.aggregator.doctor")
>  .aggregator(aggregatorExpression, aggregationStrategy)
>  .convertBodyTo(String.class)
>  .to("hospital:camel.hospital.nurse.send.aggregator.doctor.receiver");
> 
> 
> However I still have some open questions targeting the
> AggregationStrategy? 
> Is there some timeout mechanism or how long does the AggregationStrategy
> wait for messages to arrive? 
> And under which conditions does the AggregationStrategy send out
> aggregated
> messages?
> 
> Thanks for replies
> Robert
> 

The strategy of dealing with content is up to you. You can play with
text/xml content (eg. combining subsequent blocks into one single xml
document) or even use objects and build collection. If you are asking about
controlling aggregator's "lifecycle" there are AFAIR 3 properties: timeout,
batch size and even predicate for aggregating process completion so you have
full control over it.

Przemek

-----Ursprüngliche Nachricht-----
Von: P.Budzik [mailto:[EMAIL PROTECTED] 
Gesendet: Samstag, 12. Jänner 2008 16:47
An: [email protected]
Betreff: Re: Aggregation problems


Hi,

Probably what you need is not an AggregationStrategy, but specific
Expression implementor that make Aggregator corelate messages with the same
JMSCorrelationID. Try use something like that:

Expression aggregatorExpression = new Expression(){
                    public Object evaluate(Exchange exchange) {
                        JmsMessage in = (JmsMessage) exchange.getIn();
                        String jmsCorrelationID = null;
                        try {
                            jmsCorrelationID =
in.getJmsMessage().getJMSCorrelationID();
                        } catch (JMSException e) {
                            throw new RuntimeException(e);
                        }
                        return jmsCorrelationID;
                    }
                }; 

Such class should be passed to aggregate(...)

Przemek
--
View this message in context:
http://www.nabble.com/Aggregation-problems-tp14774855s22882p14774997.html
Sent from the Camel - Users mailing list archive at Nabble.com.




-- 
View this message in context: 
http://www.nabble.com/Aggregation-problems-tp14774855s22882p14775708.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to