Agenda NodeJS - Dynamic Events

Viewed 8

I have a need to dynamically schedule jobs. The situation is:

User creates a schedule in the front end. This will be send to a express backend.

The job is scheduled using agenda.every.

I can see the data peristed to Mongo and the event is defined with agenda.define. This works the first time!

The problem is that when the server is restarted the schedule never runs. ( its running in a container on K8s).

It appears for the schedule to run I have to call agenda.define passing in the name of the event, every time the server starts?

As I have 1000 + users and each has 8 schedules I could have 8000 events to redfine!

I could run a loop getting the name of the events with agenda.jobs and then pass this to agenda.define.

Is this the correct way to handle this? If so i will do this.

Does any one have any other suggestions?

Are there any recommened limits on the number of jobs to schedule per instance of Agenda?

Thanks

JT

0 Answers
Related