-
1. Re: File Binding Reference - Dynamic File Name
kcbabo Feb 24, 2014 9:25 PM (in response to fenoloco)1 of 1 people found this helpfulBy "at runtime" do you mean:
1) Replace the value in the application with something different at startup.
2) Replace the value in the application with something different per message.
For (1), you can use property substitution. For (2), I assume we are talking about a producer endpoint. I have not tested this, but if you have a CamelFileName context property in your SY message and configure the context mapper on the binding to propagate that property, then that should end up in the Camel message passed to the Camel file component.
-
2. Re: Re: File Binding Reference - Dynamic File Name
fenoloco Feb 25, 2014 2:49 PM (in response to kcbabo)1 of 1 people found this helpfulHi,
Thank for the reply.
I'm in the case number 2.
I managed to change the fileName but I can not make the same with the directory. I imagine that the directory property is get in a different way, can you give me a clue?
I add my code maybe someone else need it or want to leave a comment.
@Override public CamelBindingData decompose(Exchange exchange, CamelBindingData target) throws Exception { .............. org.apache.camel.Message msg = target.getMessage(); // Define file name String fileName = ""; msg.setHeader(org.apache.camel.Exchange.FILE_NAME, fileName); .............
Thanks in advance.
-
3. Re: File Binding Reference - Dynamic File Name
kcbabo Feb 26, 2014 8:23 AM (in response to fenoloco)I don't think you can change the root directory name, but you could use sub-directories in your filename path to put messages in separate folders within the root directory. More info available in the Camel File component documentation:
-
4. Re: File Binding Reference - Dynamic File Name
jdestef Mar 8, 2014 10:13 AM (in response to fenoloco)Hi,
Trying to do the same thing that your code outlines. grab the message from the target and set the headers. Still the file name is the switchyard messageId. Would have a working sample that you could share? I must have something set incorrectly. I'm using the supplied switchyard file binding.
Thanks
-
5. Re: File Binding Reference - Dynamic File Name
fenoloco Mar 12, 2014 10:11 AM (in response to jdestef)Hi,
Which version are you using, it works for me on 1.1.0 Final. I can´t share my example; is a comercial product.
If you have an small example, share it and I will give it a look.-
-
6. Re: File Binding Reference - Dynamic File Name
jdestef Mar 12, 2014 11:21 AM (in response to fenoloco)Thanks,
I think I have it working by using the ReferenceInvoker and setting the property CamelFileName to the name of the file I want produced. This seems to work as long as there is no fileName element in the switch producer configuration. Thanks for your offer.
-
7. Re: File Binding Reference - Dynamic File Name
tadayosi Jul 8, 2014 2:56 AM (in response to fenoloco)For anyone who is interested, I created a working dynamic filename example project:
samples-switchyard/ftp-filename at master · tadayosi/samples-switchyard · GitHub