2

I am evaluating arangodb "Community Edition" v.3.7.6 in Cluster Mode. At the moment, I am trying to figure out, how to reliably schedule regularly reoccurring jobs via queues in my foxx service. I have read the documentation pages here and here and came up with the following scripts:

setup.js

const queues = require('@arangodb/foxx/queues')

var myQueue = undefined
try {
    myQueue = queues.get('myqueue')
} catch (e) {
    myQueue = queues.create('myqueue')
}

myQueue.push({
    name: "myRegularTask",
    mount: module.context.mount
},
{to: 'hello@example.com', body: 'Hello world'},
{
  repeatTimes: Infinity,
  repeatUntil: Date.now() + (24 * 60 * 60 * 1000),
  repeatDelay: 5 * 1000
});

myRegularTask.js

'use strict';

const db = require('@arangodb').db;

const testCollection = db._collection('test')

testCollection.save({text: 'sample text'});

manifest.json

{
  "$schema": "http://json.schemastore.org/foxx-manifest",
  "main": "index.js",
  "engines": {
    "arangodb": "^3.0.0"
  },
  "name": "myapp",
  "version": "0.1.0",
  "tests": "test/**/*.js",
  "scripts": {
    "setup": "scripts/setup.js",
    "myRegularTask": "scripts/myRegularTask.js"
  }
}

So what I think it is supposed to do is that it registers a regular job that is executed every 5 seconds (and inserts a document into my testCollection) once I have installed my foxx service. It actually does that sometimes. However, most of the time nothing happens, no matter how long I wait.

And that is the question of this post: How come that the behavior of above code is undeterministic to me? What am I doing wrong to get it working always?

Thanks Seb

Sebiya
  • 21
  • 1
  • Are there any errors logged? Did you try to 'play' with the `maxFailure` settings, setting `backOff` to 0? – Tom Regner Jul 08 '21 at 09:38
  • Hi @TomRegner , unfortunately I would not know where to look for error logs on the arango db user interface ... I can see system related collections such as _queues or _jobs. When I added a queue, i could see a job was created (and visible in the _jobs collection) but there was no indication whether the job is being executed successfully or if there was any failure. – Sebiya Jul 08 '21 at 23:59
  • @TomRegner Thanks for the hint regarding `maxFailure` and `backOff` though. When I find some more time, I might give it a shot. Right now, frankly I am fed up with try and error... seems like I am unable to find the information I need inside the arangodb documentation.. – Sebiya Jul 09 '21 at 00:06

0 Answers0