Database Reference
In-Depth Information
We check whether the web service call succeeded or failed.
If the web service call succeeded, we extract the weather data.
If the web service call failed, we prepare some failure data.
We store the result into the database.
We write a message to the logfile indicating that the task ran to completion.
While you are typically interested in the final computed result of
your XQuery, when your query is running within the scheduler
there is nowhere for the result to be implicitly sent to. If you wish
to understand or retain the result of your query, you are responsiā€
ble for either explicitly storing it into the database from the query
using the xmldb:store XQuery extension function or writing it to
a logfile using the fn:trace or util:log XQuery functions.
Java Jobs
As noted previously, if you wish to write a scheduled job in Java, you can implement
either a user job or a system task job . For each option, eXist provides appropriate
interfaces and abstract classes to assist in your implementation. Once you have
implemented the appropriate class, you need to place your compiled class onto
eXist's classpath, which you typically do by placing a JAR file of your code and any
dependent JAR files into $EXIST_HOME/lib/user . Remember that you may have to
restart eXist for the JVM class loader to see your new JAR files!
When writing a Java job, you must be careful to return any brokers
that you borrow from the broker pool you are provided with and
ensure that you release any locks that you have taken on collections
or resources. Failure to do so can reduce the connections available
to the database and leave resources inaccessible until eXist is
restarted. It is strongly recommended to use the Java try / catch /
finally pattern to release any acquired resources in the finally
block. In addition, you should be aware that you cannot keep state
in member variables of your Job class across invocations; instead,
you should keep any nontransient state in a singleton (remember
to synchronize access where needed) or store it into the database.
Java user job
Most often, developers will want to implement user jobs, which you do by extending
the abstract class org.exist.scheduler.UserJavaJob . When extending this class,
Search WWH ::




Custom Search