Can anyone help me in this issue about apache camel? I'm trying to execute a route that acts as follow:
1 - Send a XML archive to a Webservice 1.1 - If the response is OK, move this file to a directory called "successImport" 1.2 - If the response fails, move this same file to a directory called "failImport"
The actual problem is: Camel is moving my files to both directoris, failImport and successImport, even when the webservice process fail.
This is a snippet of my code:
String webservice310 = "localhost:8080/api/importxml/version310";
String webservice200 = "localhost:8080/api/importxml/version200";
String dir = "c:/imports/";
from("file:" + dir + "?include=.*.xml&delay=1000&move=successImport")
.process(new ProcessorXml())
.doTry()
.choice()
.when(header("version").isEqualTo("3.10"))
.to("restlet:"+ webservice310 + "?restletMethod=post")
.when(header("version").isEqualTo("2.00"))
.to("restlet:"+ webservice200 + "?restletMethod=post")
.endDoTry()
.doCatch(XmlBindException.class)
.to("file://" + dir + "failImport");
When I change the route for something like this:
from("file:" + dir + "?include=.*.xml&delay=1000&move=successImport&moveFailed=failImport")
Camel works good, but any error goes to the "failImport" even though this is not triggered by the exception I'm expecting. How can I move only exceptions that I'm specifying on my route "doCatch" block?
No comments:
Post a Comment