I just printed out the body of the exchange in the camel aggregator and it is
returning null. I guess this is one reason why the xpath is not working.
Could this be a bug in camel 2.2 ?
Here are two snippets; one just printing the expected body as is , and the
second which routes it through the aggregator
-------------------------------------------------------------------------------------------------------
public class MyRouteBuilder extends RouteBuilder {
public void configure() {
System.out.println("In MyRouteBuilder------------------");
Namespaces ns = new Namespaces("p",
"http://nsn.com/obs/mw/medfra/snmpbc")
.add("xsd", "http://www.w3.org/2001/XMLSchema");
from("jbi:service:http://servicemix.apache.org/test/camel-receiver")
.to("log:tutorial");
--------------------------------------------------------------------------------------------------------------------
INFO - AutoDeploymentService - Directory: hotdeploy: Finished
installation of archive: inmc-snmp-sa-1.0-SNAPSHOT.jar
INFO - tutorial -
Exchange[BodyType:javax.xml.transform.stream.StreamSource,
Body:<p:snmp-getResponse xmlns:p="http://nsn.com/obs/mw/medf
ra/snmpbc" xmlns:xsi="http://www.w3.org/2001/XMLSchema">
<p:NE ipaddr="10.58.128.10"/>
<p:get-response> 1.3.6.1.6.3.1.1.4.1.0
<p:variable-bindings>
<p:varBinding name="1.3.6.1.6.3.1.1.4.1.0">noSuchObject</p:varBinding>
</p:variable-bindings>
</p:get-response>
</p:snmp-getResponse>
--------------------------------------------------------------------------------------------------------------------
public class MyRouteBuilder extends RouteBuilder {
public void configure() {
from("jbi:service:http://servicemix.apache.org/test/camel-receiver")
.aggregate(new MyAggregationStrategy()) //camel 2
//.aggregator(new MyAggregationStrategy()) //camel 1.6
.header("*")
//.xpath("string(/p:snmp-getResponse/p:NE/@ipaddr)",String.class, ns)
//.completedPredicate(header("completed").isEqualTo("true")) //camel
1.6
.completionPredicate(header("completed").isEqualTo("true"))
//camel 2
//.to("jbi:endpoint:http://servicemix.apache.org/test/file_sender_getbulk/endpoint");
// 3
.to("log:tutorial");
---------------------------------------------------------------------------------------------------------
public class MyAggregationStrategy implements AggregationStrategy {
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
String oldBody = oldExchange.getIn().getBody(String.class);
String newBody = newIn.getBody(String.class);
System.out.println("---------------------------");
System.out.println("New Body "+newBody);
System.out.println("Old Body "+oldBody);
System.out.println("---------------------------");
String oldBody2 = oldExchange.getOut().getBody(String.class);
String newBody2 = newExchange.getOut().getBody(String.class);
System.out.println("---------------------------");
System.out.println("New Body Out "+newBody2);
System.out.println("Old Body Out "+oldBody2);
System.out.println("---------------------------");
-------------------------------------------------------------------------------------
INFO - AutoDeploymentService - Directory: hotdeploy: Finis
tion of archive: inmc-snmp-sa-1.0-SNAPSHOT.jar
Going in aggregate 123i4
Exception in Aggregator
java.lang.NullPointerException
Going in aggregate 123i4
---------------------------
New Body null
Old Body null
---------------------------
---------------------------
New Body Out null
Old Body Out null
---------------------------
getIp - inXMLnull
Exception caught getIp java.lang.NullPointerException
Ip-->
Status-->
Exception in Aggregator
java.lang.NumberFormatException: For input string: ""
--
View this message in context:
http://servicemix.396122.n5.nabble.com/servicemix-3-3-1-and-camel-core-2-3-0-tp1624310p2840430.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.