How to configure retrieving folder once when camel start? - apache-camel

My requirement as below,
Starting camel,then processing all of the files with file component ,which is located some folder once.this route is just used once.
So how to configure with spring DSL?
Thanks advance.

Split your requirement as follow
Starting camel
Your research item, cover this will be off-topic in stackoverflow
processing all of the files with file component
Use file component by from, i.e. from("file://...")
is located some folder once
Set a proper parent directory and then use recursive option in file component to enable sub-directories lookup. For further control, you may check following options minDepth, maxDepth, filterDirectory, filter
this route is just used once
Use repeatCount option in file component to control fire count, i.e. repeatCount=1
Combine them together, you have
from("file://path/to/parent/directory?repeatCount=1&recursive=true")
... // follow by your route logic

Related

How to create a dynamic basePath in Next.js config

I want to do three things in my application, but I’m not figuring out how I could do that using Next.js router.
The default URL of the application should be 'https://localhost:3000/en'
It should also be possible to have 'https://localhost:3000/es' as a valid URL
Anything different than '/es' should redirect to '/en'
(This parameter will influence on the displayed language of the application.)
Considering those three points, should I create inside pages folder a new folder called language and put my index.tsx file and all the others routes that I have?
Example here
If I do that, what are the rules that I should create on my next.config.js to match with the criteria that I listed above? If not, what could be another approach to solve this?

Apache camel multiple dynamic route for single file

I have a dynamic route which reads and process a file and there could be multiple files. Each route is processing single file at a time. When request comes for different files at the same time there is no issue, as it creates unique URI based on file name. I also need to support parallel request for same file.
I am getting below exception for parallel request.
Failed to start route MyFileProcessorDynamicRoute because of Multiple consumers for the same endpoint is not allowed.
Is there a way where i can create chaining of route at runtime?
Thanks in advance.
As per your context I am getting to know, you have to use same file(having same name) to be used in different route at same time.
You can achieve by setting flag kind of thing(sequence order in which route has to run) in route were you need to process the same name file. By doing this you cannot start second route without completing first route.
This might tricky but achievable.
Thanks.

Apache Camel File component base path

How do I manage to configure the File component of my Camel Context, so that all directory paths provided to its endpoints are prepended with some base path?
For example, if someone writes
file:input/customer12?include=.*\.csv
it will effectively be
file:/usr/local/share/app/exchange/input/customer12?include=.*\.csv
For example, I get the component during the Camel Context initialization like this:
FileComponent file = CAMELCONTEXT.getComponent("file", FileComponent.class);
What do I do next? createComponentConfiguration()?
addition: It's a standalone cli app which I want to be runnable from any directory
The easiest solution is start your app under folder /usr/local/share/app/exchange , but this is not an option as state in addition requirement
If you have a layer between your user input and your code, then you could inject the path. For example, Java DSL with RouteBuilder.
The last solution is override Camel's file component in component class before it create the actual endpoint.

CakePHP HTMLHelper for Scripts uses extra param in URL causing scripts not to load

For our project we've been using a lot of subdomains, but for one particular section we just use a redirect that sends the user of a specific type from the normal dashboard at /dashboard to /manager/dashboard.
This has been in place for months and works, but now in an element within our view we're trying to load some scripts using the HTMLHelper, but it's appending the /manager to the URL.
How can I have it just access the webroot version at
/js/path
instead of
/manager/js/path
using a generic element that is used throughout our application in different subdomains like it doesn't now (with the exception of /manager/*?
Try adding
Configure::write('App.jsBaseUrl','js/');
to your bootstrap.php file.
Alternatively, if you provide the full path to the .js file (starting with a leading /), CakePHP will ignore whatever App.jsBaseUrl holds, and will render the correct path.

Camel Sftp - Download Multiple Files

I am able to successfully download one/all files from a sftp directory using the following uri in canmel route definition
Download all files
"sftp://userName#serverName/directoryName?knownHostsFile=./known_hosts&privateKeyFile=./id_rsa&proxy=#proxy&noop=true"
Download one file
"sftp://userName#serverName/directoryName?knownHostsFile=./known_hosts&privateKeyFile=./id_rsa&proxy=#proxy&noop=true&fileName=one.txt"
My requirement is to download a specific list of files = one.text, two.text.
How can I pass list of fileNames to the Camel route? Preferablly I am looking for a solution where in I can specify something like the below
"sftp://userName#serverName/directoryName?knownHostsFile=./known_hosts&privateKeyFile=./id_rsa&proxy=#proxy&noop=true&fileName=one.txt,two.txt"
The Camel FTP component extends the File component and many of the options from file is also applicable for the FTP component, so read this page
http://camel.apache.org/file2
You can for example use include to specify a regular expression that matches the files you want. Or implement a custom filter class and use the filter option, etc.

Resources