0

Is there any way to call a xQuery Script stored in eXist which for instance uses transform:transform on a large number of files and let it run in the Background? Right now, I can call my script via the Browser and it will take several minutes - would be nice to have it run in the background. Is this possible?

---Edit

It seems that xQuery Tasks are always running in the background, there is no need to wait from them to finish when calling them via a Webinterface in eXist. So what I'm looking for is merely a way to forward to another url when a query is called.

karkraeg
  • 445
  • 4
  • 18
  • 1
    Why not just change your .xq file to execute all of the transformations and avoid the complexity of one query forwarding ("calling back") to another URL? If you really want to trigger an HTTP request, you could use the `hc:send-request` function. See https://exist-db.org/exist/apps/fundocs/view.html?uri=http://expath.org/ns/http-client. – Joe Wicentowski Nov 28 '18 at 17:01
  • My xq executes all Transformations, but when I call via my Webinterface (my eXist App) the browser just keeps on reloading – I’m looking for a way to call by xq and immediately redirect to another page. The xq exectution sometimes takes hours to complete. I’ll look into `hc:send-request`, thanks! – karkraeg Nov 30 '18 at 08:20
  • Trigger the transformation and redirect the browser at once. This is easy with the XQ ability to return more values: `return (request:redirect-to(URI), transform:transform())`. With this, the browser is redirected and the process runs ‘in the background’. – Honza Hejzl Dec 07 '18 at 08:51
  • 1
    Thanks @HonzaHejzl but when testing I’m getting this error: `Cannot compile xquery: err:XPST0017 Function request:redirect-to() is not defined in module namespace: http://exist-db.org/xquery/request` I can’t find any Info about this in eXist’s XQuery Function Documentation… – karkraeg Dec 07 '18 at 13:04
  • @kbecker87 Sorry, I it is `response:redirect-to()` [The docs](http://exist-db.org/exist/apps/fundocs/view.html?uri=http://exist-db.org/xquery/response&location=java:org.exist.xquery.functions.response.ResponseModule&details=true). – Honza Hejzl Dec 07 '18 at 17:50
  • Using `response:redirect-to()` alone works, but when I call a Xquery with a chain of functions and `response:redirect-to()` being the first, the redirection only takes place _after_ the query has executed completely. I will try to use `util:eval` to call another external xquery and then redirect the user. Will report here in 2019 Have nice holidays! – karkraeg Dec 19 '18 at 14:34

1 Answers1

0

Can you explain what you mean by background? If you call the script it will run. If running the script makes exist unresponsive you need to increase its memory. You can run multiple scripts, and you can schedule a CRON job to execute a query at specific intervals. You can also execute a script via the REST endpoint, in case you don't want to use a browser?

duncdrum
  • 723
  • 5
  • 13
  • With running in the background I mean "call the script like `http://127.0.0.1/exist/apps/myapp/my_script.xq` and forward to another html page within eXist". I will try using the REST endpoint - would that be simply by adding `rest` between `exist` and `apps` in the URL? – karkraeg Nov 26 '18 at 11:35
  • http://www.exist-db.org/exist/apps/doc/devguide_rest.xml note the section about passing xsl. I m afraid URL forwarding is different topic all together. – duncdrum Nov 26 '18 at 13:11