This is what comes form my log:

11:38:31,370 | INFO  |  0: Batch Sender | MyAggregationStrategy            |
rg.tempuri.MyAggregationStrategy   23 | new: Exchange[Message:
StringSource[<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";><soap:Body><_ns_:RequestResponse
xmlns:_ns_="http://services.locator/";><return
xmlns:tns="http://services.locator/";><code>-1</code><message>Unknown
error</message></return></_ns_:RequestResponse></soap:Body></soap:Envelope>]]
11:38:31,370 | INFO  |  0: Batch Sender | MyAggregationStrategy            |
rg.tempuri.MyAggregationStrategy   30 | newly formed: Exchange[Message:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
<soap:Body>
<kxml>
<request>
<amountText>230</amountText>
<sellAccSelBox>current</sellAccSelBox>
</request>
</kxml>
</soap:Body>
</soap:Envelope>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";><soap:Body><_ns_:RequestResponse
xmlns:_ns_="http://services.locator/";><return
xmlns:tns="http://services.locator/"; ><code>-1</code><message>Unknown
error</message>xmlns:xsi="... [Body clipped after 1000 chars, total length
is 1301]]


In the log above, myaggregationstrategy prints the concatenated message, but
the problem is that the printed exchange is not returned to <from
uri="direct:ProcessorServices" />, only the last exchange gets to <from
uri="direct:ProcessorServices" />.

I hope this is clear.





Stan Lewis-3 wrote:
> 
> Hmmm, I tested your aggregator code as-is on 2.2-SNAPSHOT here and it
> works fine:
> 
> 2010-01-22 09:41:18,444 [0: Batch Sender] INFO
> JoinStringAggregatorTest       - New: Exchange[Message: one]
> 2010-01-22 09:41:18,444 [0: Batch Sender] INFO
> JoinStringAggregatorTest       - old: Exchange[Message: one]
> 2010-01-22 09:41:18,445 [0: Batch Sender] INFO
> JoinStringAggregatorTest       - new: Exchange[Message: two]
> 2010-01-22 09:41:18,445 [0: Batch Sender] INFO
> JoinStringAggregatorTest       - newly formed: Exchange[Message:
> onetwo]
> 2010-01-22 09:41:18,800 [0: Batch Sender] INFO  AGGREGATION_RESULT
>         - Exchange[BodyType:String, Body:onetwo]
> 
> What version are you running there, can you try the latest snapshot?
> 
> On Fri, Jan 22, 2010 at 8:39 AM, lekkie <[email protected]> wrote:
>>
>> See code below:
>>
>> package org.tempuri;
>>
>> import org.apache.camel.Exchange;
>> import org.apache.camel.Header;
>> import org.apache.camel.Message;
>> import org.apache.camel.processor.aggregate.AggregationStrategy;
>> import org.apache.commons.logging.Log;
>> import org.apache.commons.logging.LogFactory;
>>
>> public class MyAggregationStrategy implements AggregationStrategy {
>>
>>        private static final transient Log LOG =
>> LogFactory.getLog(MyAggregationStrategy.class);
>>
>>        public Exchange aggregate(Exchange oldExchange, Exchange
>> newExchange)
>>        {
>>
>>                if (oldExchange == null)
>>                {
>>                        LOG.info("old is null only new available");
>>                        LOG.info("New: " + newExchange);
>>                return newExchange;
>>        }
>>
>>                LOG.info("old: " + oldExchange);
>>                LOG.info("new: " + newExchange);
>>
>>                Message newIn = newExchange.getIn();
>>                String oldBody =
>> oldExchange.getIn().getBody(String.class);
>>                String newBody = newIn.getBody(String.class);
>>                newIn.setBody(oldBody + newBody);
>>
>>                LOG.info("newly formed: " + newExchange);
>>
>>                return newExchange;
>>        }
>>
>>
>> }
>>
>>
>>
>>
>> Stan Lewis-3 wrote:
>>>
>>> Can you post what you're doing in your aggregation strategy?
>>>
>>> On Fri, Jan 22, 2010 at 4:05 AM, lekkie <[email protected]> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I want to combine messages from 2 different exchanges into a single
>>>> exchange, from the EIP patterns aggregation strategy seems to be right
>>>> pattern to use.
>>>>
>>>> However, after reading the doc
>>>> (http://camel.apache.org/aggregator.html),
>>>> I
>>>> followed the instructns but my aggregation strategy only returns the
>>>> last
>>>> exchange, even though I specifically configured it to send messages
>>>> only
>>>> when the outbatchsize is 2.
>>>>
>>>> I implemented a custom aggregationstrategy with shoulld combine my
>>>> exchanges
>>>> into one. I log the event in the class and it works fine, what is
>>>> beyond
>>>> me
>>>> is why it returns only the last exchange.
>>>>
>>>>
>>>> See my config here:
>>>> <bean id="myAggregatorStrategy"
>>>> class="org.tempuri.MyAggregationStrategy"/>
>>>>
>>>> <osgi:camelContext xmlns="http://camel.apache.org/schema/spring";
>>>> trace="true">
>>>> <route>
>>>>        <from uri="direct:RequestProcessor" />
>>>>        <to uri="xslt:requestToSOAP.xsl"/>
>>>>        <wireTap uri="direct:AggregatorServices"/>
>>>>        <to uri="xslt:requestToManager.xsl"/>
>>>>        <convertBodyTo type="javax.xml.transform.dom.DOMSource" />
>>>>        <to uri="nmr:{http://services.locator/}Service:ServicesPort"/>
>>>>        <to uri="direct:AggregatorServices"/>
>>>> </route>
>>>>
>>>> <route>
>>>>        <from uri="direct:AggregatorServices" />
>>>>        <aggregate strategyRef="myAggregatorStrategy" outBatchSize="2">
>>>>                <correlationExpression>
>>>>                        <constant>true</constant>
>>>>                </correlationExpression>
>>>>                <to uri="direct:ProcessorServices"/>
>>>>         </aggregate>
>>>> </route>
>>>>
>>>>  <route>
>>>>        <from uri="direct:ProcessorServices" />
>>>>        <to uri="log:Response"/>
>>>> </route>
>>>> </osgi:camelContext>
>>>>
>>>> log:Response only print out response from <to
>>>> uri="nmr:{http://services.locator/}Service:ServicesPort"/>.
>>>>
>>>> Meanwhile, the log inside myStratRef (myAggregatorStrategy), which I
>>>> ask
>>>> to
>>>> concatenate the old & new exchanges shows both exchanges were
>>>> concatenated.
>>>> How do I get this concatenated exchange to be sent (to log:Resposne)?
>>>>
>>>> Regards.
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/Aggregator%27s-not-returning-combined-exchanges%2C-only-returns-last-exchange-tp27270355p27270355.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Aggregator%27s-not-returning-combined-exchanges%2C-only-returns-last-exchange-tp27270355p27273231.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Aggregator%27s-not-returning-combined-exchanges%2C-only-returns-last-exchange-tp27270355p27275141.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to