You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by watcher <pa...@daly.ws> on 2008/03/19 10:26:35 UTC

FileComponent Routing

I'm a new user to camel.

I successfully set up a example as follows.



public class CamelTest extends RouteBuilder {
	
	public void configure() throws Exception {
	 
from("file:c:\\temp").to("bean:fileuploadService?methodName=process").convertBodyTo(File.class);		
	}
}


I what to route the the message to a different route based on the file name.
For e.g. if the filename contains the word "report" I would like to redirect
it to another folder and not through a bean.

I think I should use a filter like below but I'm unsure what I need to do.
What does the "foo" relate to?
    from("seda:a").filter(header("foo").isEqualTo("bar")).to("seda:b");

I've configure camel to use the Juel (el) expression language. Version 1.2.0

-Thanks in advance.

-- 
View this message in context: http://www.nabble.com/FileComponent-Routing-tp16141656s22882p16141656.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: FileComponent Routing

Posted by Gary Tully <ga...@gmail.com>.
the header should be set correctly by the FileConsumer component,

something like the following will work:

from("file:c:\\temp").filter(header(FileComponent.HEADER_FILE_NAME).matchesRegex("A-.*")).to(...);
from("file:c:\\temp").filter(header(FileComponent.HEADER_FILE_NAME).matchesRegex("B-.*")).to(...);

I first tried using .contains("-") rather than the matchesRegex but
the contains matcher is targeted at collections and undesirably
results in an equals evaluation of the file name rather than a string
contains.

Gary.

On 25/03/2008, watcher <pa...@daly.ws> wrote:
>
>
>  You can get the name of the file using the header property =
>  org.apache.camel.file.name
>
>  from("seda:a").filter(header("org.apache.camel.file.name").isEqualTo("file.txt")).to("seda:b");
>
>  Regards,
>
>  Charles
>
>
>
> Thanks Charles
>   I think it's required to set the header property first.
>
>  from("seda:a").convertBodyTo(File.class)
>                 .setHeader(FileComponent.HEADER_FILE_NAME, el("${in.file.name}"))
>
>  .filter(header(FileComponent.HEADER_FILE_NAME).isEqualTo("file.txt")).to("seda:b");
>
>
>  --
>  View this message in context: http://www.nabble.com/FileComponent-Routing-tp16141656s22882p16272451.html
>
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>

Re: FileComponent Routing

Posted by watcher <pa...@daly.ws>.

You can get the name of the file using the header property =
org.apache.camel.file.name

from("seda:a").filter(header("org.apache.camel.file.name").isEqualTo("file.txt")).to("seda:b");

Regards,

Charles


Thanks Charles
 I think it's required to set the header property first.

from("seda:a").convertBodyTo(File.class)
		.setHeader(FileComponent.HEADER_FILE_NAME, el("${in.file.name}"))
               
.filter(header(FileComponent.HEADER_FILE_NAME).isEqualTo("file.txt")).to("seda:b");

-- 
View this message in context: http://www.nabble.com/FileComponent-Routing-tp16141656s22882p16272451.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: FileComponent Routing

Posted by cmoulliard <cm...@gmail.com>.
You can get the name of the file using the header property =
org.apache.camel.file.name

from("seda:a").filter(header("org.apache.camel.file.name").isEqualTo("file.txt")).to("seda:b");

Regards,

Charles

watcher wrote:
> 
> I'm a new user to camel.
> 
> I successfully set up a example as follows.
> 
> 
> 
> public class CamelTest extends RouteBuilder {
> 	
> 	public void configure() throws Exception {
> 	 
> from("file:c:\\temp").to("bean:fileuploadService?methodName=process").convertBodyTo(File.class);		
> 	}
> }
> 
> 
> I what to route the the message to a different route based on the file
> name. For e.g. if the filename contains the word "report" I would like to
> redirect it to another folder and not through a bean.
> 
> I think I should use a filter like below but I'm unsure what I need to do.
> What does the "foo" relate to?
>     from("seda:a").filter(header("foo").isEqualTo("bar")).to("seda:b");
> 
> I've configure camel to use the Juel (el) expression language. Version
> 1.2.0
> 
> -Thanks in advance.
> 

-- 
View this message in context: http://www.nabble.com/FileComponent-Routing-tp16141656s22882p16145836.html
Sent from the Camel - Users mailing list archive at Nabble.com.