使用Camel I过滤文件名时出现错误

时间:2016-02-14 18:47:58

标签: java spring apache-camel

我试图在apache Camel上使用文件名过滤器。 我收到IllegalArgumentException类型的错误 - 见下文。 你能建议吗?

spring xml:

<bean id="adoFilter" class="calypsox.bllInterfaces.cashMgn.cashMgnAdo.AdoFileFilter"/>
                <camelContext xmlns="http://camel.apache.org/schema/spring"
                                id="cashMgn">
                                <propertyPlaceholder id="cashMgnProperty"
                                                location="${bll.resources.env}/cashMgn.properties" />
                                <route id="cashMgnAdo">
                                                <from
                                                                uri="file:{{cashMgnAdoFileDir}}?filter=#adoFilter;move=.org/${date:now:yyyyMMdd}/${file:name}&amp;readLock=changed&amp;readLockCheckInterval=2000&amp;readLockTimeout=10000&amp;moveFailed=.failed" />
                                                <convertBodyTo type="java.lang.String" />
                                                <to uri="bean:cashMgnHandler?method=handleCashMgnAdo" />
                                </route>

                </camelContext>

java过滤器类:

     public class AdoFileFilter<T> implements GenericFileFilter<T> {
                public boolean accept(GenericFile<T> file) {
                                // we want all directories
                                // if (((File) file).isDirectory()) {
                                // return true;
                                // }

                                // we dont accept any files starting with skip in the name
                                return true;// !file.getFileName().startsWith("skip");
                }
}

例外:

Caused by: java.lang.IllegalArgumentException: Could not find a suitable setter for property: filter as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.apache.camel.component.file.GenericFileFilter with value #adoFilter;move=.org/${date:now:yyyyMMdd}/${file:name}

                at org.apache.camel.util.IntrospectionSupport.setProperty(IntrospectionSupport.java:341)

                at org.apache.camel.util.IntrospectionSupport.setProperties(IntrospectionSupport.java:291)

                at org.apache.camel.util.EndpointHelper.setProperties(EndpointHelper.java:225)

                at org.apache.camel.impl.DefaultComponent.setProperties(DefaultComponent.java:200)

                at org.apache.camel.component.file.GenericFileComponent.createEndpoint(GenericFileComponent.java:65)

                at org.apache.camel.component.file.GenericFileComponent.createEndpoint(GenericFileComponent.java:36)

                at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:75)

                at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:432)

                ... 28 more

1 个答案:

答案 0 :(得分:2)

您必须将查询参数与&amp;分开。在您的filtermove参数之间改为使用分号。