Struggling to get camel in action filter/xpath examples working
davesargrad opened this issue · 3 comments
I'm starting to work through the examples in the book. I've found the filter xpath to be difficult to get working. I've tried several iterations at this point. I've also verified my xpath online.
I've tried several variants (starting with the filter on "test attribute" provided in the book).
In general, my filter drops all the messages. They make it to the outbox if I eliminate the filter.
I commented out the intial attempt at filtering test orders, and then i tried some other variants. Here is my code. In general, I'd expect files to be placed into outbox if they pass the filter. Yet all my files get dropped and dont make it to outbox.
Here is a filter that i think should work (checking value of an element rather than an attribute)
The XML (inbox/order4.xml)
<?xml version="1.0" encoding="UTF-8"?>
<person><city>London</city></person>
The route
from("file:data/inbox?noop=true")
.log("Received order: ${header.CamelFileName}")
.filter().xpath("/person/city='London'")
.log("Please process valid order: ${header.CamelFileName}")
.to("file:data/outbox");
I should see the logged message indicating that order4 is procssed and placed in the outbox, and I should see this file in the outbox. Yet I see neither the log, nor the file.
The actual cat'd content of order4.
The online validation using an xpath tester:
What am I missing?
Hi @davsclaus
If you have a few minutes to offer a suggestion, would be greatly appreciated. In the mean time, I am enjoying your book.
My issue was the way I was creating Uber jars.. I now have filtering working. See solution here.
Good to hear you got it working.
See also this FAQ on the Camel website
https://camel.apache.org/manual/latest/faq/how-do-i-use-a-big-uber-jar.html