Accessing `danilelsz/system` components from inside Quartz(ite) scheduler job

Dear all,

I am building system made of several components using danielsz/system, utilizing postgresql database and quartzite scheduler. My system specification is like:

(defsystem dev-system
           [:db (make-db) ;; postgres database
            :scheduler (new-scheduler) ;; quartzite scheduler

And quartzite job definition:

(defjob MyJob
  (if (not (do-somethig DB)) ;; do some operations on database
    (delete-job-from-scheduler (:id ctx) SCHEDULER)))

The issue is how to access system components, that is db and scheduler from inside of the Quartz(ite) job.

I’ve tried doing something like:

(qj/build (qj/of-type MyJob)
            (qj/using-job-data {"id" (:id job)
                                "db" db
                                "scheduler" scheduler})
            (qj/with-identity (job-key job)))

But this feels super bad - I need to use durable job storage in Quartz, so in essence I will be storing database connection details persistently in the database… And different story is that I won’t be able to serialize db, nor scheduler to store it in Postgres in first place.

So, in short, what’s the proper way of accessing system components in cases like that, where there is no straightforward way of passing data?
Or maybe there is some way how to pass job execution context in quartzite?


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.