file component to access doneFileName option

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

file component to access doneFileName option

wyuan4
I have one requirement to transfer file depends on the done file name

for example, in the drop folder inputDir, if there is file named
123456.done dropped, I need to move all the file whose name including
123456 to outputDir. if there is file named 456789.done dropped, I need to
move all the files whose name including 456789 to outputDir.

I know that we have doneFileName=${filel.name}.done, but how to reuse this
${file.name} in the include regular expression to filter file name?

file://inputDir?delete=true&include=^.*_ ${file.name
}_[0-9]{5}.dat$&doneFilenName=${file.name}.ready


thanks

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Weiquan Yuan
Located in Ottawa, Canada
Reply | Threaded
Open this post in threaded view
|

Re: file component to access doneFileName option

Claus Ibsen-2
Hi

Instead of using doneFileName which AFAIR is a 1:1 with file and done
file, then you can implement a custom file filter and configure on the
file endpoint, and then return true|false whether you can find a done
file name yourself via the java api.


On Mon, Dec 2, 2019 at 9:41 PM WEIQUAN YUAN <[hidden email]> wrote:

>
> I have one requirement to transfer file depends on the done file name
>
> for example, in the drop folder inputDir, if there is file named
> 123456.done dropped, I need to move all the file whose name including
> 123456 to outputDir. if there is file named 456789.done dropped, I need to
> move all the files whose name including 456789 to outputDir.
>
> I know that we have doneFileName=${filel.name}.done, but how to reuse this
> ${file.name} in the include regular expression to filter file name?
>
> file://inputDir?delete=true&include=^.*_ ${file.name
> }_[0-9]{5}.dat$&doneFilenName=${file.name}.ready
>
>
> thanks
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Weiquan Yuan
> Located in Ottawa, Canada



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Reply | Threaded
Open this post in threaded view
|

Re: file component to access doneFileName option

wyuan4
Thanks, Claus. I agree with you and I implement the GenericFileFilter as
below

public class FileTransferFilter implements GenericFileFilter {

@Override
public boolean accept(GenericFile pathname) {
     // we don't accept any files starting with skip in the name
     return !pathname.getFileName().startsWith("skip");
  }
}

but for my case, skip is not hard coded value, it is dynamic variable from
ready file name, how could I pass this variable to this filter?

On Mon, Dec 2, 2019 at 11:20 PM Claus Ibsen <[hidden email]> wrote:

> Hi
>
> Instead of using doneFileName which AFAIR is a 1:1 with file and done
> file, then you can implement a custom file filter and configure on the
> file endpoint, and then return true|false whether you can find a done
> file name yourself via the java api.
>
>
> On Mon, Dec 2, 2019 at 9:41 PM WEIQUAN YUAN <[hidden email]>
> wrote:
> >
> > I have one requirement to transfer file depends on the done file name
> >
> > for example, in the drop folder inputDir, if there is file named
> > 123456.done dropped, I need to move all the file whose name including
> > 123456 to outputDir. if there is file named 456789.done dropped, I need
> to
> > move all the files whose name including 456789 to outputDir.
> >
> > I know that we have doneFileName=${filel.name}.done, but how to reuse
> this
> > ${file.name} in the include regular expression to filter file name?
> >
> > file://inputDir?delete=true&include=^.*_ ${file.name
> > }_[0-9]{5}.dat$&doneFilenName=${file.name}.ready
> >
> >
> > thanks
> >
> > --
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > Weiquan Yuan
> > Located in Ottawa, Canada
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Weiquan Yuan
Located in Ottawa, Canada
Reply | Threaded
Open this post in threaded view
|

Re: file component to access doneFileName option

Claus Ibsen-2
Hi

You can use java api, to look for the done file name.

You know the target file name.
Then do a file list and check if there is a done file name for it.


On Tue, Dec 3, 2019 at 3:52 PM WEIQUAN YUAN <[hidden email]> wrote:

>
> Thanks, Claus. I agree with you and I implement the GenericFileFilter as
> below
>
> public class FileTransferFilter implements GenericFileFilter {
>
> @Override
> public boolean accept(GenericFile pathname) {
>      // we don't accept any files starting with skip in the name
>      return !pathname.getFileName().startsWith("skip");
>   }
> }
>
> but for my case, skip is not hard coded value, it is dynamic variable from
> ready file name, how could I pass this variable to this filter?
>
> On Mon, Dec 2, 2019 at 11:20 PM Claus Ibsen <[hidden email]> wrote:
>
> > Hi
> >
> > Instead of using doneFileName which AFAIR is a 1:1 with file and done
> > file, then you can implement a custom file filter and configure on the
> > file endpoint, and then return true|false whether you can find a done
> > file name yourself via the java api.
> >
> >
> > On Mon, Dec 2, 2019 at 9:41 PM WEIQUAN YUAN <[hidden email]>
> > wrote:
> > >
> > > I have one requirement to transfer file depends on the done file name
> > >
> > > for example, in the drop folder inputDir, if there is file named
> > > 123456.done dropped, I need to move all the file whose name including
> > > 123456 to outputDir. if there is file named 456789.done dropped, I need
> > to
> > > move all the files whose name including 456789 to outputDir.
> > >
> > > I know that we have doneFileName=${filel.name}.done, but how to reuse
> > this
> > > ${file.name} in the include regular expression to filter file name?
> > >
> > > file://inputDir?delete=true&include=^.*_ ${file.name
> > > }_[0-9]{5}.dat$&doneFilenName=${file.name}.ready
> > >
> > >
> > > thanks
> > >
> > > --
> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > Weiquan Yuan
> > > Located in Ottawa, Canada
> >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > http://davsclaus.com @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
> >
>
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Weiquan Yuan
> Located in Ottawa, Canada



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2