Quartz Job for Recur Appoinment Blocks Daily

Tags: #<Tag:0x00007fb859779278> #<Tag:0x00007fb859779138>

(Siqlain Hanif) #1

I am trying to create a module that register the provider addition attributes like the Shifts : Morning or day shift or both , Time Period Of Shift and the on which days of the week or full week Now what i want is the quartz scheduler that runs the specific function on daily basis. How can i do that. I tried a quartz scheduler 1.8.9 on openmrs platform version 1.11.6 when i load the module it says Scheduler service not found and openmrs doesn’t start

Current Openmrs Version that i am running : 2.0.5

(Siqlain Hanif) #2

I am configuring a quartz job but getting scheduler service not found every time i load my module

(Siqlain Hanif) #3

https://pastebin.com/vnHVCuyE Openmrs.log

(Daniel Kayiwa) #4

Are your changes somewhere like on github for us to take a look?

(Siqlain Hanif) #5

Yeah https://github.com/Siqlain/RecurAppointmentBlock @dkayiwa

(Daniel Kayiwa) #6

Can you start by fixing this error? " BeanDefinitionParsingException: Configuration problem: Only one AsyncAnnotationBeanPostProcessor may exist within the context. Offending resource: URL [jar:file:/C:/OpenMRS/.openmrs-lib-cache/recurappointmentblocks/lib/recurappointmentblocks-api-1.0.0-SNAPSHOT.jar!/moduleApplicationContext.xml]"

(Siqlain Hanif) #7

This error is because <!-- <task:annotation-driven/> --> this line is been declared twice that what this error means but i have declared it once. If i comment this line out then openmrs won’t starts and stuck in refreshing context.

(Daniel Kayiwa) #8

Can you commit the change to ensure that the above error does not show up?

(Siqlain Hanif) #9

Thank you for your time i have done it. I will be pushing the latest code once i wrap it up.

(Siqlain Hanif) #10

This is the link for updated repository

(Daniel Kayiwa) #11

So with this updated repository, what is the current problem?

(Siqlain Hanif) #12

I have been able to run the schedule job Now what i am doing is getting all the providers which threw this error. https://hastebin.com/ecepopabos.cs

But i can get the providers if i manually do this

try {


Context.authenticate( "admin" , "Admin123" );

List<Provider> providers = Context.getProviderService().getAllProviders();


finally {



(Maybe this is because the my scheduled methods are running on different threads that does not get the context from the main thread --> Guessing)

I have pushed the code and the omod file to the repo you can check

(Daniel Kayiwa) #13

Can you point us to the class where you have the code to get providers?

(Siqlain Hanif) #14

This class contains the code to get all providers

This Class contains the context.getService method

(Daniel Kayiwa) #15

From your AppointmentBlockRecurrTask. getProviders(), can you use this? Daemon.runInDaemonThread(Runnable runnable, DaemonToken token);

(Daniel Kayiwa) #16

And here is an example in the idgen module: https://github.com/openmrs/openmrs-module-idgen/search?utf8=✓&q=daemontoken

(Siqlain Hanif) #17

Yeah by making module activator daemonaware. i am able to get the providers.

Now the question is how can i be able to write a cron expression if i use the idgen runnable tasks in my code. Like i want to run this function daily at 12 :00 am

(Daniel Kayiwa) #18

Are you creating a scheduled task with an interface like this? https://demo.openmrs.org/openmrs/admin/scheduler/scheduler.form?taskId=3

(Siqlain Hanif) #19

No not from this interface. My module just got its own tasks which are going to be configured in the module.

(Daniel Kayiwa) #20

Can we have a look at one such a task?