[
https://issues.apache.org/jira/browse/CAMEL-6367?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
jeff updated CAMEL-6367:
------------------------
Description:
A new option is available for the stream:file to close it when done
(closeOnDone). This option is appeared in 2.11 after my jira
(https://issues.apache.org/jira/browse/CAMEL-6147)
File unlock (or released or closed) looks to doesn't works fine if last line is
not passed to the endpoint
Example :
We have a CSV with X line. We want to write a part of it in a file out_1.csv
and a second part in a file out_2.csv according to a business rule, in my
example the rule is after two lines readed.
An example is :
from("file://C:/Temp/camel/rep1/?noop=true")
.log("start process file => ${file:name}")
.split()
.tokenize("\n")
.streaming()
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
// After 2 lines, next lines are rejected via an exchange
property
i++ ;
if( i > 2) {
exchange.setProperty("FILE_1", true );
} else {
exchange.setProperty("FILE_1", false);
}
}
})
.choice()
.when(property("FILE_1").isEqualTo(Boolean.TRUE))
.to("stream:file?fileName=C:/Temp/camel/rep1/out/out_1.csv&closeOnDone=true")
.when(property("FILE_2").isEqualTo(Boolean.TRUE))
.to("stream:file?fileName=C:/Temp/camel/rep1/out/out_2.csv&closeOnDone=true")
.end()
.end()
.log("end process file => ${file:name}")
.end()
;
It create two files, and out_1.csv is still locked.
Solution : Seems like the logic in stream producer should sync (lock) and not
per method which is wrong.
Or maybe better yet do not have a shared output stream.
By the way, the problem appears not on if there are two files. It appears if
the last exchange is not passed to the endpoint.
Example with only one file :
from("file://C:/Temp/camel/rep1/?noop=true")
.split()
.tokenize("\n")
.streaming()
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
// After 2 lines, next lines are rejected via an
// exchange property
i++;
if (i > 2) {
exchange.setProperty("FILE_1", false);
} else {
exchange.setProperty("FILE_1", true);
}
}
})
.choice()
.when(property("FILE_1").isEqualTo(Boolean.TRUE))
.to("stream:file?fileName=C:/Temp/camel/rep1/out/out_1.csv&closeOnDone=true")
.end()
.end()
.end();
was:
A new option is available for the stream:file to close it when done
(closeOnDone). This option is appeared in 2.11 after my jira
(https://issues.apache.org/jira/browse/CAMEL-6147)
File unlock (or released or closed) looks to doesn't works fine if last line is
not passed to the endpoint
Example :
We have a CSV with X line. We want to write a part of it in a file out_1.csv
and a second part in a file out_2.csv according to a business rule, in my
example the rule is after two lines readed.
An example is :
from("file://C:/Temp/camel/rep1/?noop=true")
.log("start process file => ${file:name}")
.split()
.tokenize("\n")
.streaming()
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
// After 2 lines, next lines are rejected via an exchange
property
i++ ;
if( i > 2) {
exchange.setProperty("FILE_1", true );
} else {
exchange.setProperty("FILE_1", false);
}
}
})
.choice()
.when(property("FILE_1").isEqualTo(Boolean.TRUE))
.to("stream:file?fileName=C:/Temp/camel/rep1/out/out_1.csv&closeOnDone=true")
.when(property("FILE_2").isEqualTo(Boolean.TRUE))
.to("stream:file?fileName=C:/Temp/camel/rep1/out/out_2.csv&closeOnDone=true")
.end()
.end()
.log("end process file => ${file:name}")
.end()
;
It create two files, and out_1.csv is still locked.
Solution : Seems like the logic in stream producer should sync (lock) and not
per method which is wrong.
Or maybe better yet do not have a shared output stream.
> The logic in stream producer should sync (lock) and not per method which is
> wrong
> ---------------------------------------------------------------------------------
>
> Key: CAMEL-6367
> URL: https://issues.apache.org/jira/browse/CAMEL-6367
> Project: Camel
> Issue Type: Bug
> Components: camel-stream
> Affects Versions: 2.11.0
> Reporter: jeff
>
> A new option is available for the stream:file to close it when done
> (closeOnDone). This option is appeared in 2.11 after my jira
> (https://issues.apache.org/jira/browse/CAMEL-6147)
> File unlock (or released or closed) looks to doesn't works fine if last line
> is not passed to the endpoint
> Example :
> We have a CSV with X line. We want to write a part of it in a file out_1.csv
> and a second part in a file out_2.csv according to a business rule, in my
> example the rule is after two lines readed.
> An example is :
> from("file://C:/Temp/camel/rep1/?noop=true")
> .log("start process file => ${file:name}")
> .split()
> .tokenize("\n")
> .streaming()
> .process(new Processor() {
>
> public void process(Exchange exchange) throws Exception {
> // After 2 lines, next lines are rejected via an exchange
> property
> i++ ;
> if( i > 2) {
> exchange.setProperty("FILE_1", true );
> } else {
> exchange.setProperty("FILE_1", false);
> }
> }
> })
> .choice()
> .when(property("FILE_1").isEqualTo(Boolean.TRUE))
>
> .to("stream:file?fileName=C:/Temp/camel/rep1/out/out_1.csv&closeOnDone=true")
> .when(property("FILE_2").isEqualTo(Boolean.TRUE))
>
> .to("stream:file?fileName=C:/Temp/camel/rep1/out/out_2.csv&closeOnDone=true")
> .end()
> .end()
> .log("end process file => ${file:name}")
> .end()
> ;
> It create two files, and out_1.csv is still locked.
> Solution : Seems like the logic in stream producer should sync (lock) and not
> per method which is wrong.
> Or maybe better yet do not have a shared output stream.
> By the way, the problem appears not on if there are two files. It appears if
> the last exchange is not passed to the endpoint.
> Example with only one file :
> from("file://C:/Temp/camel/rep1/?noop=true")
> .split()
> .tokenize("\n")
> .streaming()
> .process(new Processor() {
> public void process(Exchange exchange) throws Exception {
> // After 2 lines, next lines are rejected via an
> // exchange property
> i++;
> if (i > 2) {
> exchange.setProperty("FILE_1", false);
> } else {
> exchange.setProperty("FILE_1", true);
> }
> }
> })
> .choice()
> .when(property("FILE_1").isEqualTo(Boolean.TRUE))
>
> .to("stream:file?fileName=C:/Temp/camel/rep1/out/out_1.csv&closeOnDone=true")
> .end()
> .end()
> .end();
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira