I have a software that monitoring a folder and activate a Camel processing , I am using Cemel Spring 4.0 with spring context :
camel-context.xml
<route id="toWS" errorHandlerRef="myDeadLetterErrorHandler">
<from uri="file:/home/devuser/work/HB/HB_HOME/monitoring?delay=2000&move=../mov_done&moveFailed=../mov_fail"/>
<process ref="initProcessor"/>
<bean ref="excel" method="setCard(${in.header.X_CARD})"/>
<log message="Header: $simple{in.headers[X_FILENAME]}" loggingLevel="INFO" logName="org.savino.hb.dataprovider" />
<bean ref="excel"/>
<bean ref="finalProcessor"/>
</route>
Main Class :
public class DataLoader {
private static final Logger logger = LoggerFactory.getLogger(DataLoader.class);
public static void main(String... args) throws Exception {
logger.info("*** HB DataLoader v 1.0 ***");
ApplicationContext appContext = new ClassPathXmlApplicationContext("camel-context.xml");
//InitProcessor ip = (InitProcessor) appContext.getBean("initProcessor");
CamelContext camelContext =new SpringCamelContext(appContext);
new Main().run(args);
//Main main = new Main(DataLoader.class);
//main.run(args);
//main.start();
//ApplicationContext appContext = new ClassPathXmlApplicationContext("camel-context.xml");
}
}
I would use dynamic folder monitoring reading the value of folder from args .I tryed
- <from uri="file:${arg_var}? ...
- <from uri="file:{{arg_var}}? ...
but got every time the same :
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: file://$%7Bfolder%7D?delay=2000&move=..%2Fmov_done&moveFailed=..%2Fmov_fail due to: Invalid directory: ${folder}. Dynamic expressions with ${ } placeholders is not allowed. Use the fileName option to set the dynamic expression.
at org.apache.camel.impl.engine.AbstractCamelContext.doGetEndpoint(AbstractCamelContext.java:856)
at org.apache.camel.impl.engine.AbstractCamelContext.getEndpoint(AbstractCamelContext.java:758)
at org.apache.camel.support.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:60)
at org.apache.camel.reifier.AbstractReifier.resolveEndpoint(AbstractReifier.java:195)
at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:96)
at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:76)
... 23 more
Caused by: java.lang.IllegalArgumentException: Invalid directory: ${folder}. Dynamic expressions with ${ } placeholders is not allowed. Use the fileName option to set the dynamic expression. at org.apache.camel.component.file.FileComponent.buildFileEndpoint(FileComponent.java:55) at org.apache.camel.component.file.GenericFileComponent.createEndpoint(GenericFileComponent.java:58) at org.apache.camel.component.file.GenericFileComponent.createEndpoint(GenericFileComponent.java:38) at org.apache.camel.support.DefaultComponent.createEndpoint(DefaultComponent.java:170) at org.apache.camel.impl.engine.AbstractCamelContext.doGetEndpoint(AbstractCamelContext.java:822) ... 28 more
There is a way to ruse dynamic folder supplyed from java args ?