camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dermoritz <tantea...@hotmail.com>
Subject problem/glitch/bug in file component?
Date Tue, 11 Nov 2014 15:44:34 GMT
in my camel app (standalone jar, guice) i have 2 routes that use/create a
file buffer. So there are routes like this
from(someEndpoint).<do split or other processing>.to("file:/bufferFolder")
from("file:/bufferFolder").to(otherEndpoint)

In many cases i want to set the file name. In one case i include the time
stamp in an other case i include split-index. The code looks like this:

FileEndpoint fileEndpoint = getContext().getEndpoint("file:/bufferFolder",
FileEndpoint.class);
fileEndpoint.setFileName("${file:name.noext}-${property.CamelSplitIndex}.${file:name.ext}");

The camel experts here will see that this won't work with routes above,
because FileEndpoint is "Singleton". And setting up to file endpoints with
same "uri" will result in one endpoint. And setting filename in one of them
(producer) will also set it on the other (consumer). But setting file name
on consumer means setting a strict filter, in my cases files will never
match.

The solution is simple: If file name is set as uri parameter on producer
site two distinct endpoints are created. So this is working:
FileEndpoint fileEndpoint =
getContext().getEndpoint("file:/bufferFolder?fileName=${file:name.noext}-${property.CamelSplitIndex}.${file:name.ext}",
FileEndpoint.class);

My questions are:
- Is my explanation correct?
- Is my solution the only/best solution?

To be discussed:
In my opinion using uri parameters or a setter (imho to be preferred) should
yield the same result/behavior?!

I think it is a problem to use "FileName" on both sites?!

At the end the results/ behavior should be at least documented. So if there
are substantial difference in using uri parameters (/ xml) or using java 
setters (compiler checked/type safe) it should be pointed out (creating or
not creating new objects is substantial imho).




--
View this message in context: http://camel.465427.n5.nabble.com/problem-glitch-bug-in-file-component-tp5758931.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message