You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Knut-Håvard Aksnes <kh...@gmail.com> on 2014/10/28 12:41:34 UTC

Problems configuring FileIdempotentRepository

I have had problems with a FileIdempotentRepository configured like this
(spring):

	<bean id="issuesFetched"
		class="org.apache.camel.processor.idempotent.FileIdempotentRepository">
		<property name="fileStore" value="issuesImported.dat" />
		<property name="cacheSize" value="5000" />
		<property name="maxFileStoreSize" value="51200000" />
	</bean>

I then in a test case


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
"/META-INF/spring/pays-issue-import-test.xml" })
public class ITIssueImport {

    @Inject
    @Named("issuesFetched")
    FileIdempotentRepository issuesFetched;

    @Test(timeout = 510000)
    public void issueImport() throws InterruptedException, IOException {
        Assert.assertNotNull(issuesFetched);
       
Assert.assertEquals("issuesImported.dat",issuesFetched.getFilePath());
        Assert.assertEquals(51200000L, issuesFetched.getMaxFileStoreSize());
        Assert.assertEquals(5000, issuesFetched.getCacheSize());
        Thread.sleep(500000);
    }

}

It fails at the last assert, telling me that cache size is null.

I need to set the value to something larger than 0 as a cache with a fixed
maximum size of 0 is useless.
I am trying to use this on a file route where I have to use noop=true and
need to avoid rereading files after a restart. My spring configuration is
based on documentation for the file component.



--
View this message in context: http://camel.465427.n5.nabble.com/Problems-configuring-FileIdempotentRepository-tp5758212.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problems configuring FileIdempotentRepository

Posted by Knut-Håvard Aksnes <kh...@gmail.com>.
I am using Camel 2.12.4

This doesn't help so I assume that the problem isn't related to the
cacheSize setter:

	<bean id="issuesFetched"
		class="org.apache.camel.processor.idempotent.FileIdempotentRepository"
		factory-method="fileIdempotentRepository">
		<constructor-arg name="fileStore" value="issuesImported.dat" />
		<constructor-arg name="cacheSize" value="5000" />
		<constructor-arg name="maxFileStoreSize" value="51200000" />
	</bean>



--
View this message in context: http://camel.465427.n5.nabble.com/Problems-configuring-FileIdempotentRepository-tp5758212p5758222.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problems configuring FileIdempotentRepository

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah the code in doStart / loadStore should create the file store if
it does not exists. Then Camel will create the store on startup, and
the file is there.

I logged  ticket to get this fixed
https://issues.apache.org/jira/browse/CAMEL-7989

On Wed, Oct 29, 2014 at 4:57 PM, Henryk Konsek <he...@gmail.com> wrote:
>> The underlying problem is that if the idempotent repository file doesn't
>> exist Camel doesn't seem to create it.
>
> If you can reproduce the issue with the Maven example, you could
> create a Jira issue with bug report.
>
> Cheers.
>
>
> --
> Henryk Konsek
> http://henryk-konsek.blogspot.com



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: Problems configuring FileIdempotentRepository

Posted by Henryk Konsek <he...@gmail.com>.
> The underlying problem is that if the idempotent repository file doesn't
> exist Camel doesn't seem to create it.

If you can reproduce the issue with the Maven example, you could
create a Jira issue with bug report.

Cheers.


-- 
Henryk Konsek
http://henryk-konsek.blogspot.com

Re: Problems configuring FileIdempotentRepository

Posted by Knut-Håvard Aksnes <kh...@gmail.com>.
The underlying problem is that if the idempotent repository file doesn't
exist Camel doesn't seem to create it. If I create it as an empty file the
repository seems to always be truncated during the save phase: Even with
only a few files there and a with a huge file store size.
In the last case I get this message after reading only 6 files with a
maxFileStoreSize of 200000000  :
2014-10-28 16:44:18,533 INFO  FileIdempotentRepository - Trunking idempotent
filestore: issuesImported.dat

The repository is left empty.




--
View this message in context: http://camel.465427.n5.nabble.com/Problems-configuring-FileIdempotentRepository-tp5758212p5758233.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problems configuring FileIdempotentRepository

Posted by Henryk Konsek <he...@gmail.com>.
Hi,

> I need to set the value to something larger than 0 as a cache with a fixed
> maximum size of 0 is useless.

Keep in mind that FileIdempotentRepository.html#getCacheSize() [1]
return the current, not maximum the size of the cache.

Laters!

[1] http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/idempotent/FileIdempotentRepository.html#getCacheSize()

-- 
Henryk Konsek
http://henryk-konsek.blogspot.com