camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aida <>
Subject [ConsumerTemplate] CamelLocks deleted before file is completely processed
Date Fri, 20 Sep 2013 11:55:53 GMT

I'm using the consumer template for reading files, and I'm experiencing
something that makes me think that I'm not using it correctly. What happens
to me is:

1. I have a dir with multiple files
2. The consumer template reads one of those files, creating a camelLock file
for the file that is going to be processed
3. The consumer template reads another file (same route, different thread)
and, since the camelLock of the previous file still exists, deletes it and
creates the camelLock for the file that is going to be processed now (the
previous file haven´t ended its processing and haven´t been "finished" using
the doneUnitOfWork)
4. The same for each file that is read (the camelLocks are removed and a
WARNING appears in the log " Deleting orphaned lock file: .../..

I think that maybe this is because I'm creating a new consumerTemplate each
time I have to read something (could it be?), because I have seen that it
has a ConsumerCache.

The problem is that I use some "rules" to use it (one of them creating the
CT each time), because of some problems I have had in the past:

- Don´t use the disconnect option for FTPs (Nullpointer, at least in Camel
2.9.0 that leaves threads alive, Camel post in [1])
- Create a new Consumer template each time I read a file (same reasons as
previous sentence) and stop it after use
- I synchronize the method that consumes an endpoint because otherwise, when
reading files in parallel instead of reading two files, the consumer reads
one twice

In case it can helps, I put my code here:

    	ConsumerTemplate cTemplate = camelContext.createConsumerTemplate();
    	Exchange dataExchange = null;
    	if(timeoutInMilis == 0){
    		dataExchange = cTemplate.receiveNoWait(endpoint2Consume);
    		dataExchange = cTemplate.receive(endpoint2Consume, timeoutInMilis);
        try {
		} catch (Exception e) {
			log ...

Thanks in advance		
Camel Version: 2.10.4		

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message