1. MotechSchedulerGateway vs MotechSchedulerService
Currently there are two different ways to schedule a job, although
both ultimately go through the MotechSchedulerService bean defined in
the scheduler module. The MotechSchedulerGateway is injected into the
application-wide Context. It provides four methods, while the service
provides those and more. A few modules are utilizing the gateway and
some are using the service. Besides its inclusion in platform-common's
Context, the gateway can be found in the motech-appointments, motech-
outbox and motech-demo modules. The service can be found in the
scheduletracking, message-campaign and pillreminder modules. A
schedule queue is used when using the MotechSchedulerGateway. If you
directly invoke the service, you actually move to a single queue
architecture, where only an event queue is shuttles messages. A
separate queue for scheduling could distribute the workload.
Which is the preferred method going forward?
2. Core platform dependency on the rules engine
There is some question to whether or not the KnowledgeBaseManager,
rule repository, and rule file/bundle loading are always needed in the
core platform. We can envision uses of the platform where Drools or
other rule management are not necessary. For example, message
campaigns and schedule tracking allow any user to be enrolled, and
this may be the intention of a particular deployment. The behavior and
rules of these message campaigns are inherent in their specification
and configuration.
Do we want to have include the rules engine/drools as part of core
platform ?
If you build the WAR file from the project, the server, server-
api, common and ivr platform modules are all pulled in as
dependencies. However, the scheduler module is excluded from this. It
should be known that the MotechSchedulerGateway in the common platform
will not work properly (or at all) without the scheduler module. It
attempts to push scheduled jobs to the schedule queue, but they will
never be shuttled to the payload router unless the scheduler's context
has been started, providing an in adapter for the schedule queue.
Should the scheduler module be part of the core platform build ?
3. Testing of some code
We were able to test both the MotechSchedulerGateway and
MotechSchedulerService, by using the MotechScheduler class in the
scheduler module. The MotechSchedulerGateway has an unschedule method
that is routed to the MotechSchedulerService. If you attempt to test
this code without making any changes, an exception will be thrown
claiming that the service implementation does not have all of the
proper methods to handle messages. This is because the unschedulejob
in the service that only takes a String for job ID is private. Making
this method public fixes the issue. Another problem is that both the
inbound adapters for the event and schedule queue are named jmsin.
This creates a conflict if you are running both in the same Spring
context. What happens is that a job is sent to the schedule queue,
which is dequeued then received and routed by the application, which
schedules the job with the service implementation. When the Quartz
trigger is activated and the job is executed, an event is raised,
which is never dequeued because of the overlapping names in the same
context. This is fixed by renaming one of the two adapters.
What is the status of this code ? Should we be using this code going
forward ?
Thanks, Russell and Bruce