You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by icucode <fr...@gmail.com> on 2009/01/14 20:31:42 UTC
File component - dynamic file path?
Hi,
I have a environment with three components
"client->queue(ActiveMQ)->server". On the client I currently use spring
remoting to invoke the servers service and a java file with routing
information is located at the server. My messages consists of a single
String and I would like to place these messages in a directory on the server
and at the same time invoke a method for further processing.
/ Save message to file
queue
\ Process message
My problem is that I can't decide upon the best way to set the file path
dynamically. I have an ID for each message that is known on the client
side(But it is not present in the message) and I would like to know if it is
possible to add this ID using setHeader(FileComponent.HEADER_FILE_NAME,
ID/filename) - how can I do that when I'm using spring remoting? (Don't have
a message object)
If I set this on the client is this information then accessible on the
server using a simple "to("file://orders/?noop=true)" (Should save the file
into orders/ID/filename)?
If it matters the client and server are running in separate java instances.
Thanks for the great software
--
View this message in context: http://www.nabble.com/File-component---dynamic-file-path--tp21463419s22882p21463419.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: File component - dynamic file path?
Posted by icucode <fr...@gmail.com>.
Ok, then you can't use Spring remoting on it's own because you can't set
header properties through it. If I instead use an instance of the Exchange
class and manipulates the message (getIn()) it works.
Thanks
Claus Ibsen-2 wrote:
>
> Hi
>
> You can send the Filename as a JMS property. From the client side set body
> - payload
> - a JMS property with the filename (its like key=value)
>
> Then on the server side where you are using Camel you can get the
> filename as a header in the IN message.
> For instance if the JMS property is:
> key=myfilename
> value=hello.txt
>
> from("activemq:queue:files").to("file://inbox/expression=${in.header.myfilename}",
> "bean:processFile");
>
> Then the filename stored will be: ./inbox/hello.txt
>
> See file language expression for dynamic filenames:
> http://activemq.apache.org/camel/file-language.html
>
> You can also set it with a setHeader DSL
>
> from("activemq:queue:files").setHeader(FileComponent.HEADER_FILENAME,
> header("myfilename")).to("file://inbox/", "bean:processFile");
>
>
>
> On Wed, Jan 14, 2009 at 8:31 PM, icucode <fr...@gmail.com> wrote:
>>
>> Hi,
>>
>> I have a environment with three components
>> "client->queue(ActiveMQ)->server". On the client I currently use spring
>> remoting to invoke the servers service and a java file with routing
>> information is located at the server. My messages consists of a single
>> String and I would like to place these messages in a directory on the
>> server
>> and at the same time invoke a method for further processing.
>>
>> / Save message to file
>> queue
>> \ Process message
>>
>> My problem is that I can't decide upon the best way to set the file path
>> dynamically. I have an ID for each message that is known on the client
>> side(But it is not present in the message) and I would like to know if it
>> is
>> possible to add this ID using setHeader(FileComponent.HEADER_FILE_NAME,
>> ID/filename) - how can I do that when I'm using spring remoting? (Don't
>> have
>> a message object)
>> If I set this on the client is this information then accessible on the
>> server using a simple "to("file://orders/?noop=true)" (Should save the
>> file
>> into orders/ID/filename)?
>>
>> If it matters the client and server are running in separate java
>> instances.
>>
>>
>> Thanks for the great software
>> --
>> View this message in context:
>> http://www.nabble.com/File-component---dynamic-file-path--tp21463419s22882p21463419.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
>
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
>
>
--
View this message in context: http://www.nabble.com/File-component---dynamic-file-path--tp21463419s22882p21541243.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: File component - dynamic file path?
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
You can send the Filename as a JMS property. From the client side set body
- payload
- a JMS property with the filename (its like key=value)
Then on the server side where you are using Camel you can get the
filename as a header in the IN message.
For instance if the JMS property is:
key=myfilename
value=hello.txt
from("activemq:queue:files").to("file://inbox/expression=${in.header.myfilename}",
"bean:processFile");
Then the filename stored will be: ./inbox/hello.txt
See file language expression for dynamic filenames:
http://activemq.apache.org/camel/file-language.html
You can also set it with a setHeader DSL
from("activemq:queue:files").setHeader(FileComponent.HEADER_FILENAME,
header("myfilename")).to("file://inbox/", "bean:processFile");
On Wed, Jan 14, 2009 at 8:31 PM, icucode <fr...@gmail.com> wrote:
>
> Hi,
>
> I have a environment with three components
> "client->queue(ActiveMQ)->server". On the client I currently use spring
> remoting to invoke the servers service and a java file with routing
> information is located at the server. My messages consists of a single
> String and I would like to place these messages in a directory on the server
> and at the same time invoke a method for further processing.
>
> / Save message to file
> queue
> \ Process message
>
> My problem is that I can't decide upon the best way to set the file path
> dynamically. I have an ID for each message that is known on the client
> side(But it is not present in the message) and I would like to know if it is
> possible to add this ID using setHeader(FileComponent.HEADER_FILE_NAME,
> ID/filename) - how can I do that when I'm using spring remoting? (Don't have
> a message object)
> If I set this on the client is this information then accessible on the
> server using a simple "to("file://orders/?noop=true)" (Should save the file
> into orders/ID/filename)?
>
> If it matters the client and server are running in separate java instances.
>
>
> Thanks for the great software
> --
> View this message in context: http://www.nabble.com/File-component---dynamic-file-path--tp21463419s22882p21463419.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
--
/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/