camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mta38 <mtaraud....@orange-ftgroup.com>
Subject Is it possible to use aggregator with xpath
Date Thu, 16 Oct 2008 14:06:18 GMT

Hi all,
I try to use "aggregator" with "xpath" but i have some strange behaviour.
Here is my spring config file :

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:tns="http://activemq.apache.org/schema/core"
	xmlns:g1="urn:mynamespace:myservice"
	xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring-1.4.0.xsd 
 		http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core.xsd">



	<bean id="myProcessor" class="aggregator.MyProcessor" />
	<bean id="myAggregatorStrategy" class="aggregator.MyAggregationStrategy"/>
	

	<camelContext id="myCamelContext"
xmlns="http://activemq.apache.org/camel/schema/spring">

		<!-- Let's try processor "aggregator"  -->	
		<!-- We use our own aggregation strategy define in
aggregator.MyAggregationStrategy class -->

		<!-- Route with a defined batch size to stop collection of exchange. -->
		<route>
			<from uri="direct:aggreg-start" />		
			 <aggregator strategyRef="myAggregatorStrategy" batchSize="2">			 	
							
				<xpath>/soapenv:Envelope/soapenv:Body/g1:creerMarche</xpath>	
				<!-- simple>header.client</simple-->
									
				<to uri="mock:result" /> 					
			</aggregator>	
		</route>

	
	</camelContext>

</beans>

This is my java code

public void testSendingMessagesWithCustomAggregator() throws Exception {
        
        result.expectedMessageCount(1);
             
        producer.sendBodyAndHeader(REQUEST_MESSAGE, "client","client");
        producer.sendBodyAndHeader(REQUEST_MESSAGE2, "client","client");        
        result.await(20,TimeUnit.SECONDS);
        
        
          
        List<Exchange> list = result.getReceivedExchanges();
        for (Exchange exchange : list) {
            Message in = exchange.getIn();
            String body = in.getBody(String.class);        
            LOG.info("Result: " + body); 
        }
        

When I use <simple>header.client</simple> as predicate, my aggregation
strategy code is executed.
But when I try to use
<xpath>/soapenv:Envelope/soapenv:Body/g1:creerMarche</xpath> my aggregation
strategy code is never executed.

Here is the REQUEST_MESSAGE values:
	
private static final String REQUEST_MESSAGE = "<soapenv:Envelope
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:g1=\"
urn:mynamespace:myservice\" xmlns:g11=\"urn:mynamespace:myservice \">"
		  +"<soapenv:Header/>"
		  + "<soapenv:Body>"
		  +  "<g1:creerMarche>" 
		   + "<g1:marche>"     
		  +  "<g11:description>une desc1</g11:description>"        
		  +  "<g11:nom>nom1</g11:nom>"       
		  +  "<g11:id>id1</g11:id>"        
		 +   "</g1:marche>"     
		 + "</g1:creerMarche>"    
		+ "</soapenv:Body>" 
		+ "</soapenv:Envelope>";

All help are welcome.
Thanks in advance
Mta38

-- 
View this message in context: http://www.nabble.com/Is-it-possible-to-use-aggregator-with-xpath-tp20014324s22882p20014324.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message