Hi Bengt,

I tried to reproduce you issue in Camel trunk, and found this bug[1].
BTW, If you just want to filter the zero length file, you can take a look this unit test file[2] and change the simple expression to "${file:length} == null" as in Camel 2.4.0, ${file:length} is null if the file.length is 0.


[1]https://issues.apache.org/activemq/browse/CAMEL-3100
[2]https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIntercepEmptyFileTest.java

Willem

Bengt Rodehav wrote:
I've developed a file transfer service (for file/ftp/ftps/sftp) that uses
Camel 2.4. I need to be able to skip transferring empty files and was hoping
to use an interceptor to accomplish this. Below is the relevant code:

  String skippedUri = "file://skipped/${date:now:yyyyMMdd}/${file:name}";
  
interceptFrom().when(simple("${file:length}").isEqualTo(0)).to(skippedUri).end();

This compiles but in runtime a get the following exception when trying to
start the route:

*java.lang.NoSuchMethodError:
se.digia.connect.services.skandia.filetransfer.FileTransferService$1.simple(Ljava/lang/String;)Lorg/apache/camel/builder/ValueBuilder;
*
* **at
se.digia.connect.services.skandia.filetransfer.FileTransferService$1.configure(FileTransferService.java:279)
*
* **at
org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:295)
*
* **at
org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:250)
*
* **at
org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:236)
*
* **at
org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:498)
*
* **at
se.digia.connect.core.service.RouteServiceBase.doStart(RouteServiceBase.java:42)
*
* **at se.digia.connect.core.service.ServiceBase.start(ServiceBase.java:49)*
* **at
se.digia.connect.services.skandia.filetransfer.FileTransferService.__start(FileTransferService.java:60)
*
* **at
se.digia.connect.services.skandia.filetransfer.FileTransferService.start(FileTransferService.java)
*
* **at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)*
* **at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
*
* **at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
*
* **at java.lang.reflect.Method.invoke(Method.java:597)*
* **at org.apache.felix.ipojo.util.Callback.call(Callback.java:235)*
* **at org.apache.felix.ipojo.util.Callback.call(Callback.java:191)*
* **at
org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallback.call(LifecycleCallback.java:86)
*
* **at
org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__stateChanged(LifecycleCallbackHandler.java:162)
*
* **at
org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
*
* **at
org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:440)*
* **at
org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:321)*
* **at
org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:155)
*
* **at
org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:298)
*
* **at
org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:235)
*
* **at org.apache.felix.ipojo.IPojoFactory.updated(IPojoFactory.java:603)*
* **at
org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceFactoryUpdate.run(ConfigurationManager.java:1279)
*
* **at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:88)*

I've also tried the following:

        interceptFrom().when(simple("${file:length} ==
0")).to(skipped).end();

But it gives the following compilation error:

*The method when(Predicate) in the type InterceptDefinition is not
applicable for the arguments (ValueBuilder)*

What am I missing? This is the first time I'm using simple language and the
first time I'm using interceptors. I should also mention that I deploy the
camel route in Karaf 1.6.0 which means that OSGI could play a part I guess.

/Bengt


Reply via email to