Understanding the Dispatch Framework¶
Liferay Dispatch is a flexible framework built on top of Liferay’s Scheduler Engine. You can use it to add, execute, and schedule tasks containing any custom logic across a Liferay instance.
The Dispatch framework consists of six essential parts:
Implementations of the base
DispatchTaskExecutor interface create templates for Dispatch Tasks in a Liferay instance. Each implementation of
DispatchTaskExecutor is registered as an OSGi component and contains the logic executed by the Dispatch Task. All Dispatch Tasks are instances of Java classes that implement the
DispatchTaskExecutor interface and have the
dispatch.task.executor.type OSGi component properties. See Creating a New Dispatch Task Executor to learn more.
DispatchTrigger interface extends
PersistedModel. This entity serves as a draft for a Liferay (Quartz) trigger. It is a connection between
DispatchTaskExecutors and the Liferay scheduler engine.
DispatchMessageListener class initiates the execution of all Dispatch Task Executors. This means a new Liferay trigger is created for each scheduled instance of the
DispatchTaskExecutor service class. This trigger is created with the same destination (
liferay/dispatch/executor) and has a payload (
dispatchTriggerId) that connects the Liferay trigger with
DispatchTaskExecutor. The Liferay Scheduler engine then triggers
DispatchMessageListener at the appropriate time with a message (
DispatchMessageListener finds and runs the appropriate instance of
DispatchTaskExecutor using the
Implementations of the
DispatchTaskExecutorRegistry interface hold references to all implementations of
DispatchTaskExecutor in the portal and validate that each
dispatch.task.executor.type OSGi property value is unique.
DispatchLog interface extends
PersistedModel. This entity is responsible for persisting Dispatch Task execution logs.
DispatchConfigurator class defines properties of the Dispatch framework, such as the
executorService queue size and thread pool,
RejectedExecutionHandler, and more.