camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Hilton <>
Subject Re: De-duplicate route file name?
Date Fri, 17 May 2013 07:33:02 GMT
Solved! I didn't find anything built in, so I did the following:

1. Add a custom Producer based on the File producer, that overrides createFileName to add
a suffix when the file is a duplicate:

	class ArchiveProducer(endpoint: GenericFileEndpoint[File], operations: GenericFileOperations[File])
		extends GenericFileProducer[File](endpoint, operations) {

2. Add a custom endpoint that overrides createProducer to return my custom producer:

	class ArchiveEndpoint(uri: String, component: Component) extends FileEndpoint(uri, component)

3. Add a custom component that creates my custom endpoint, by overriding buildFileEndpoint:

	class ArchiveComponent extends FileComponent {

4. Register my custom component when setting-up Camel:

	camelContext = CamelContextBuilder()
	camelContext.addComponent("archive", new ArchiveComponent())

5. Change my file:// URIs to archive:// URIs to use my new component.


On 16 May 2013, at 12:23, Peter Hilton <> wrote:
> I’m using Camel to process files, and need to save a copy of each incoming file to
an 'archive' directory. In addition, if another file arrives with the same name as an earlier
file, I must add this to the archive with a different file name and not overwrite an existing
archive file.
> Two questions:
> 1. Does Camel have something built-in to deal with duplicate messages this way? This
differs from ‘Idempotent Consumer’ in that I don't want to skip duplicate files.
> 2. If there is nothing built in, what do I need to do to implement my own 'De-duplicating
Archive' end point?

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message