Add <service-schedule> and <cancel-scheduled-service> XML actions#719
Open
moqui-industrial wants to merge 2 commits into
Open
Add <service-schedule> and <cancel-scheduled-service> XML actions#719moqui-industrial wants to merge 2 commits into
moqui-industrial wants to merge 2 commits into
Conversation
New XML actions for high-frequency device polling and event-driven scheduled tasks:
<service-schedule task-name="..." service-name="..." mode="one-shot|at-fixed-rate|with-fixed-delay"
initial-delay="..." period="..." delay="..." time-unit="..."/>
<cancel-scheduled-service task-name="..."/>
Backed by a dedicated CustomScheduledExecutor (separate from the job runner) so short
periods (50 ms, 100 ms) do not starve long-running batch jobs.
ServiceCallScheduled fluent API mirrors ServiceCallSync/Async. scheduledFutureMap
(ConcurrentHashMap) tracks active futures by taskName for cancel-by-name support.
ServiceFacadeImpl.schedule() factory methods wire everything together and shut the
executor down cleanly on destroy().
Usage example in example/service/ExampleServices.xml.
Introduces CustomDistributedScheduledExecutor interface (ContextJavaUtil) and wires it through ServiceFacadeImpl so a Hazelcast (or other) implementation can replace the local ScheduledExecutorService for cluster-wide scheduled service execution. BREAKING: distributed-factory attribute renamed to distributed-executor-factory. Update any MoquiConf.xml that uses distributed-factory="..." accordingly. The distributed-scheduled-executor-factory attribute is new and optional; omitting it keeps the current local-only behaviour.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two new XML action elements for scheduling services declaratively from within service definitions, with optional distributed execution across a Hazelcast cluster.
New XML actions
<service-schedule><cancel-scheduled-service>Distributed executor interface
Adds
CustomDistributedScheduledExecutorinterface inContextJavaUtiland wires adistributed-scheduled-executor-factoryattribute intoMoquiConf.xsd/ServiceFacadeImpl. Whendistribute="true"and a factory implementation is present (e.g. moqui-hazelcast), the task is submitted to the distributed executor; otherwise it falls back to the localScheduledExecutorService.ScheduledServiceCallableandScheduledServiceRunnableimplementExternalizablefor transparent cross-node serialization in a cluster.Backward compatibility
Fully additive. No existing API or configuration is changed. The
distributed-scheduled-executor-factoryattribute is optional; omitting it disables distribution silently.