You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jpcook <jo...@erars.plus.com> on 2010/02/16 17:30:26 UTC

Simple File Filter

Hi,

I am trying to listen to a file directory for specific files and have
implemented my own GenericFileFilter however I am getting an error and hoped
someone could help.

I'm just using java dsl, with no spring and have this from line.
from("file://\\nolmcs2.newsonline.tc.nca.bbc.co.uk\inetpub2\syndicationengine\newsonline_uk_edition\in_pictures\?filter=com.bbc.newsi.feeds.feedaugmentor.camel.filters.PictureRSSFileFilter&noop=true&readLock=none")

My filter is very simple:
public class PictureRSSFileFilter implements GenericFileFilter {

	@Override
	public boolean accept(GenericFile pathname) {
		return pathname.getFileName().endsWith(".rss10");
	}

}

The error I am getting is:
org.apache.camel.FailedToCreateRouteException: Failed to create route
route1: Route[[From[file://\\nolmcs2.newsonline.tc.nca.bbc.co.uk\ine...
because of Failed to resolve endpoint:
file://\\nolmcs2.newsonline.tc.nca.bbc.co.uk\inetpub2\syndicationengine\newsonline_uk_edition\in_pictures\?filter=com.bbc.newsi.feeds.feedaugmentor.camel.filters.PictureRSSFileFilter&noop=true&readLock=none
due to: Could not find a suitable setter for property: filter as there isn't
a setter method with same type: java.lang.String nor type conversion
possible: No type converter available to convert from type: java.lang.String
to the required type: org.apache.camel.component.file.GenericFileFilter with
value com.bbc.newsi.feeds.feedaugmentor.camel.filters.PictureRSSFileFilter

I'm sure it is something simple, I have looked at a couple of unit tests
such as this one:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileFilterTest.java?view=markup

And wondered whether I should be using filter=#myfilter in thr uri and
whether I had to register the filter in the jndi registry or add it to the
context like you do with the routes eg)
context.addRoutes(new PictureGalleryRouteBuilder());

Really appreciate any help.
Thanks
-- 
View this message in context: http://old.nabble.com/Simple-File-Filter-tp27611010p27611010.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Simple File Filter

Posted by jpcook <jo...@erars.plus.com>.
Thanks. Yes got it working.

Will the file component pickup on changes to the file eg) each time it is
updated. Or do you have to poll it? I thought you could listen for files.

Yes the book looks good :)



Claus Ibsen-2 wrote:
> 
> Hi
> 
> You gotta register your custom filter in the registry and give it a
> logical name.
> Then that name is what you refer to in the uri with the filter id.
> 
> Take a look in the camel source code for examples.
> 
> Then search this forum for how to add your own beans to the registry.
> It has been mentioned before.
> In fact some of the unit tests will show also.
> 
> Or consider buying the book and read chapter 4 which covers beans and
> registries.
> 
> 
> 
> 
> On Tue, Feb 16, 2010 at 5:30 PM, jpcook <jo...@erars.plus.com>
> wrote:
>>
>> Hi,
>>
>> I am trying to listen to a file directory for specific files and have
>> implemented my own GenericFileFilter however I am getting an error and
>> hoped
>> someone could help.
>>
>> I'm just using java dsl, with no spring and have this from line.
>> from("file://\\nolmcs2.newsonline.tc.nca.bbc.co.uk\inetpub2\syndicationengine\newsonline_uk_edition\in_pictures\?filter=com.bbc.newsi.feeds.feedaugmentor.camel.filters.PictureRSSFileFilter&noop=true&readLock=none")
>>
>> My filter is very simple:
>> public class PictureRSSFileFilter implements GenericFileFilter {
>>
>>        @Override
>>        public boolean accept(GenericFile pathname) {
>>                return pathname.getFileName().endsWith(".rss10");
>>        }
>>
>> }
>>
>> The error I am getting is:
>> org.apache.camel.FailedToCreateRouteException: Failed to create route
>> route1: Route[[From[file://\\nolmcs2.newsonline.tc.nca.bbc.co.uk\ine...
>> because of Failed to resolve endpoint:
>> file://\\nolmcs2.newsonline.tc.nca.bbc.co.uk\inetpub2\syndicationengine\newsonline_uk_edition\in_pictures\?filter=com.bbc.newsi.feeds.feedaugmentor.camel.filters.PictureRSSFileFilter&noop=true&readLock=none
>> due to: Could not find a suitable setter for property: filter as there
>> isn't
>> a setter method with same type: java.lang.String nor type conversion
>> possible: No type converter available to convert from type:
>> java.lang.String
>> to the required type: org.apache.camel.component.file.GenericFileFilter
>> with
>> value
>> com.bbc.newsi.feeds.feedaugmentor.camel.filters.PictureRSSFileFilter
>>
>> I'm sure it is something simple, I have looked at a couple of unit tests
>> such as this one:
>> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileFilterTest.java?view=markup
>>
>> And wondered whether I should be using filter=#myfilter in thr uri and
>> whether I had to register the filter in the jndi registry or add it to
>> the
>> context like you do with the routes eg)
>> context.addRoutes(new PictureGalleryRouteBuilder());
>>
>> Really appreciate any help.
>> Thanks
>> --
>> View this message in context:
>> http://old.nabble.com/Simple-File-Filter-tp27611010p27611010.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://old.nabble.com/Simple-File-Filter-tp27611010p27612214.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Simple File Filter

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Feb 16, 2010 at 6:41 PM, jpcook <jo...@erars.plus.com> wrote:
>
> Thanks. Yes got it working.
>
> Will the file component pickup on changes to the file eg) each time it is
> updated. Or do you have to poll it? I thought you could listen for files.
>

The file will be by default moved after it has processed and thus not
picked up again.


> Yes the book looks good :)
>
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> You gotta register your custom filter in the registry and give it a
>> logical name.
>> Then that name is what you refer to in the uri with the filter id.
>>
>> Take a look in the camel source code for examples.
>>
>> Then search this forum for how to add your own beans to the registry.
>> It has been mentioned before.
>> In fact some of the unit tests will show also.
>>
>> Or consider buying the book and read chapter 4 which covers beans and
>> registries.
>>
>>
>>
>>
>> On Tue, Feb 16, 2010 at 5:30 PM, jpcook <jo...@erars.plus.com>
>> wrote:
>>>
>>> Hi,
>>>
>>> I am trying to listen to a file directory for specific files and have
>>> implemented my own GenericFileFilter however I am getting an error and
>>> hoped
>>> someone could help.
>>>
>>> I'm just using java dsl, with no spring and have this from line.
>>> from("file://\\nolmcs2.newsonline.tc.nca.bbc.co.uk\inetpub2\syndicationengine\newsonline_uk_edition\in_pictures\?filter=com.bbc.newsi.feeds.feedaugmentor.camel.filters.PictureRSSFileFilter&noop=true&readLock=none")
>>>
>>> My filter is very simple:
>>> public class PictureRSSFileFilter implements GenericFileFilter {
>>>
>>>        @Override
>>>        public boolean accept(GenericFile pathname) {
>>>                return pathname.getFileName().endsWith(".rss10");
>>>        }
>>>
>>> }
>>>
>>> The error I am getting is:
>>> org.apache.camel.FailedToCreateRouteException: Failed to create route
>>> route1: Route[[From[file://\\nolmcs2.newsonline.tc.nca.bbc.co.uk\ine...
>>> because of Failed to resolve endpoint:
>>> file://\\nolmcs2.newsonline.tc.nca.bbc.co.uk\inetpub2\syndicationengine\newsonline_uk_edition\in_pictures\?filter=com.bbc.newsi.feeds.feedaugmentor.camel.filters.PictureRSSFileFilter&noop=true&readLock=none
>>> due to: Could not find a suitable setter for property: filter as there
>>> isn't
>>> a setter method with same type: java.lang.String nor type conversion
>>> possible: No type converter available to convert from type:
>>> java.lang.String
>>> to the required type: org.apache.camel.component.file.GenericFileFilter
>>> with
>>> value
>>> com.bbc.newsi.feeds.feedaugmentor.camel.filters.PictureRSSFileFilter
>>>
>>> I'm sure it is something simple, I have looked at a couple of unit tests
>>> such as this one:
>>> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileFilterTest.java?view=markup
>>>
>>> And wondered whether I should be using filter=#myfilter in thr uri and
>>> whether I had to register the filter in the jndi registry or add it to
>>> the
>>> context like you do with the routes eg)
>>> context.addRoutes(new PictureGalleryRouteBuilder());
>>>
>>> Really appreciate any help.
>>> Thanks
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Simple-File-Filter-tp27611010p27611010.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Simple-File-Filter-tp27611010p27612213.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Simple File Filter

Posted by jpcook <jo...@erars.plus.com>.
Thanks. Yes got it working.

Will the file component pickup on changes to the file eg) each time it is
updated. Or do you have to poll it? I thought you could listen for files.

Yes the book looks good :)



Claus Ibsen-2 wrote:
> 
> Hi
> 
> You gotta register your custom filter in the registry and give it a
> logical name.
> Then that name is what you refer to in the uri with the filter id.
> 
> Take a look in the camel source code for examples.
> 
> Then search this forum for how to add your own beans to the registry.
> It has been mentioned before.
> In fact some of the unit tests will show also.
> 
> Or consider buying the book and read chapter 4 which covers beans and
> registries.
> 
> 
> 
> 
> On Tue, Feb 16, 2010 at 5:30 PM, jpcook <jo...@erars.plus.com>
> wrote:
>>
>> Hi,
>>
>> I am trying to listen to a file directory for specific files and have
>> implemented my own GenericFileFilter however I am getting an error and
>> hoped
>> someone could help.
>>
>> I'm just using java dsl, with no spring and have this from line.
>> from("file://\\nolmcs2.newsonline.tc.nca.bbc.co.uk\inetpub2\syndicationengine\newsonline_uk_edition\in_pictures\?filter=com.bbc.newsi.feeds.feedaugmentor.camel.filters.PictureRSSFileFilter&noop=true&readLock=none")
>>
>> My filter is very simple:
>> public class PictureRSSFileFilter implements GenericFileFilter {
>>
>>        @Override
>>        public boolean accept(GenericFile pathname) {
>>                return pathname.getFileName().endsWith(".rss10");
>>        }
>>
>> }
>>
>> The error I am getting is:
>> org.apache.camel.FailedToCreateRouteException: Failed to create route
>> route1: Route[[From[file://\\nolmcs2.newsonline.tc.nca.bbc.co.uk\ine...
>> because of Failed to resolve endpoint:
>> file://\\nolmcs2.newsonline.tc.nca.bbc.co.uk\inetpub2\syndicationengine\newsonline_uk_edition\in_pictures\?filter=com.bbc.newsi.feeds.feedaugmentor.camel.filters.PictureRSSFileFilter&noop=true&readLock=none
>> due to: Could not find a suitable setter for property: filter as there
>> isn't
>> a setter method with same type: java.lang.String nor type conversion
>> possible: No type converter available to convert from type:
>> java.lang.String
>> to the required type: org.apache.camel.component.file.GenericFileFilter
>> with
>> value
>> com.bbc.newsi.feeds.feedaugmentor.camel.filters.PictureRSSFileFilter
>>
>> I'm sure it is something simple, I have looked at a couple of unit tests
>> such as this one:
>> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileFilterTest.java?view=markup
>>
>> And wondered whether I should be using filter=#myfilter in thr uri and
>> whether I had to register the filter in the jndi registry or add it to
>> the
>> context like you do with the routes eg)
>> context.addRoutes(new PictureGalleryRouteBuilder());
>>
>> Really appreciate any help.
>> Thanks
>> --
>> View this message in context:
>> http://old.nabble.com/Simple-File-Filter-tp27611010p27611010.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://old.nabble.com/Simple-File-Filter-tp27611010p27612213.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Simple File Filter

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

You gotta register your custom filter in the registry and give it a
logical name.
Then that name is what you refer to in the uri with the filter id.

Take a look in the camel source code for examples.

Then search this forum for how to add your own beans to the registry.
It has been mentioned before.
In fact some of the unit tests will show also.

Or consider buying the book and read chapter 4 which covers beans and
registries.




On Tue, Feb 16, 2010 at 5:30 PM, jpcook <jo...@erars.plus.com> wrote:
>
> Hi,
>
> I am trying to listen to a file directory for specific files and have
> implemented my own GenericFileFilter however I am getting an error and hoped
> someone could help.
>
> I'm just using java dsl, with no spring and have this from line.
> from("file://\\nolmcs2.newsonline.tc.nca.bbc.co.uk\inetpub2\syndicationengine\newsonline_uk_edition\in_pictures\?filter=com.bbc.newsi.feeds.feedaugmentor.camel.filters.PictureRSSFileFilter&noop=true&readLock=none")
>
> My filter is very simple:
> public class PictureRSSFileFilter implements GenericFileFilter {
>
>        @Override
>        public boolean accept(GenericFile pathname) {
>                return pathname.getFileName().endsWith(".rss10");
>        }
>
> }
>
> The error I am getting is:
> org.apache.camel.FailedToCreateRouteException: Failed to create route
> route1: Route[[From[file://\\nolmcs2.newsonline.tc.nca.bbc.co.uk\ine...
> because of Failed to resolve endpoint:
> file://\\nolmcs2.newsonline.tc.nca.bbc.co.uk\inetpub2\syndicationengine\newsonline_uk_edition\in_pictures\?filter=com.bbc.newsi.feeds.feedaugmentor.camel.filters.PictureRSSFileFilter&noop=true&readLock=none
> due to: Could not find a suitable setter for property: filter as there isn't
> a setter method with same type: java.lang.String nor type conversion
> possible: No type converter available to convert from type: java.lang.String
> to the required type: org.apache.camel.component.file.GenericFileFilter with
> value com.bbc.newsi.feeds.feedaugmentor.camel.filters.PictureRSSFileFilter
>
> I'm sure it is something simple, I have looked at a couple of unit tests
> such as this one:
> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileFilterTest.java?view=markup
>
> And wondered whether I should be using filter=#myfilter in thr uri and
> whether I had to register the filter in the jndi registry or add it to the
> context like you do with the routes eg)
> context.addRoutes(new PictureGalleryRouteBuilder());
>
> Really appreciate any help.
> Thanks
> --
> View this message in context: http://old.nabble.com/Simple-File-Filter-tp27611010p27611010.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus