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.
Related
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
It appears I am running into issues sharing information between routes.
What is the camel pattern for passing around information ?
I looked at exchange properties but that does not stick around between routes I think...
eg:
one file has one has some configutations
i have a route to read this file
and several other routes that will act on based on the configs,
how do I accomplish this ?
I thought of puttin the values in a singleton bean, but that seems kind of ugly...
Exchange properties are preserved across routes inside camel (but there are some limitations and special cases when using splitter/aggregator etc.)
Assign ID's to all sub routes which will act on based on the config. Then get the suitable Route or RouteDefinition from camel context and check whether you can advice or share information to the route according.
ModelCamelContext modelContext;
modelContext.getRouteDefinition(String routeId) or modelContext.getRoute(String routeId)
Is there a way to build Camel routes that starts in suspended mode?
I'm looking so to say "declutch" at start up, then at some stage quickly start processing messages by just calling resumeRoute(routeId)
I could perhaps just create the route and then quickly call suspendRoute(routeId), after the route has been created, but at that stage, it would probably have consumed some messages (for instance in the case of JMS routes or polling consumer routes).
generally, you'd just disable the route by using autostartup(false)...
I assume you are asking though because you need the route started (warmed), but not active. In that case, then you should be able to use a custom route policy and some external variable to get this behavior
I have a backend data management console written with CakePHP that allows a user to manage some hierarchical data. Every time a user makes a change to the data I want to regenerate a data file (JSON in this case) that's used on the site's frontend.
The rebuild can take some time and I'd like the backend UI to be a bit more responsive. My idea is to have the JSON rebuild take place after the new page (the "your changes have been saved" page) is rendered to the user. I've got some code within the afterFilter() call back in my app_controller.php, but the page doesn't actually render in the browser until the JSON rebuild completes.
I've found code examples for plain-vanilla PHP that does things like send a Connection: Close HTTP header and/or uses output buffer flushing to tell the browser that the server's done while processing continues, but these techniques don't (as far as I can tell) work with CakePHP's structure and its own output buffering.
What I would like is a technique that would allow me to completely render a view for the user and then, once the user has their page loaded, continue executing the JSON rebuild in the background.
I realize there may be situation/setup specific concerns that could affect things, so please let me know if you've got questions about my particular application.
Thanks in advance.
those cakephp queue plugins are invented for this exact purpose:
https://github.com/MSeven/cakephp_queue
they decouple the frontend from the backend services like those file generations.
Here is a suggestion. This is how I ran long running processes from the UI for scrubbing files. First create a SHELL for doing the processing. http://book.cakephp.org/2.0/en/console-and-shells.html#Shell
This will provide the code that will run the background process you are looking to run.
Then, setup the method in the UI side to call the shell. Grab the PID and save it to the database (so you can tell when it finished).
$PID = shell_exec("/path/to/cake/console/cake SHELLNAME SHELLMETHOD");
$this->Jobs->query("UPDATE `jobs` SET `pid` = $pid WHERE `id` = $job_id");
Then you can always check to see if the process is running by checking the /proc/$PID.
I am planning to rewrite my site into CakePHP and after having spent a full week on learning it, I am still not sure how to do good custom routing in CakePHP.
This is what I want:
Keep the current url structure in www.domain.tld/en/dragons.html, or use a www.domain.tld/en/dragons, but not www.domain.tld/en/nodes/dragons.html. And also be able to use controllers on a similar path structure.
There are about 100 static pages on the entire site. I have read into multi-language routing and I think I can do it. I can also make /en/* or /en/:slug route via a PagesControler or a self-written NodesController.
My problem is that I would like to be able to mix and match url's with and without controllers, so actually what I want is that it checks if a :slug is part of the slug-list, there should still be the option to use that url with a controller.
I have created routes for both /en/contact and /en/:slugid, but it seems all queries were routed to my NodesController, even while I explicitly said that /en/contact should be routed to the ContactsController.
How can I instruct Cakephp to keep my current dictorary structure? I read the routes part of the Cakephp book, but it was extremely short and made me a little unsure about the possibility of such routing. If necessary, I'll just write a php-code that prints all routes for all slugs, so I can still write controller-routes with a similar path structure.
If a file exists in webroot (ie. app/webroot/static.html), the .htaccess file will tell Apache to serve that file before loading the CakePHP framework for requests to www.example.com/static.html.
Cake loads routes in a top-down order and will use the first matching route to handle a request. In your case, /en/contact should be above /en/:slugid, else the slugid rule will always win.
If CakePHP's routing does not accomplish what you are after, you can always implement a custom route class (book / example).