Blogs
Here are some key aspects of automation in Liferay 7.3 using the Dispatcher:
- Event-driven automation: Liferay Dispatcher allows you to define actions that are triggered by specific events within the portal. These events can be system events, such as user creation or document modification, or custom events that you define within your application. When an event occurs, the Dispatcher can execute predefined actions or workflows automatically.
- Rules and conditions: The Dispatcher provides a rule-based approach to automation. You can define rules that specify the conditions under which an action should be triggered. For example, you can define a rule that states "When a new document is uploaded and its category is 'Important,' send an email notification to specific users." The Dispatcher evaluates the rules against the events and executes the corresponding actions when the conditions are met.
- Predefined actions: Liferay 7.3 comes with a set of built-in actions that can be executed by the Dispatcher. These actions include sending email notifications, creating tasks, updating content, executing scripts, invoking web services, and more. You can combine multiple actions within a rule to achieve complex automation scenarios.
- Custom actions: In addition to the predefined actions, you can create custom actions to extend the capabilities of the Dispatcher. Custom actions allow you to integrate with external systems, execute custom business logic, or perform any other custom operations required for your automation needs.
- User-friendly interface: Liferay 7.3 provides a user-friendly interface within the administration console for configuring and
managing the Dispatcher. You can define rules, set up actions, manage triggers and events.
Benefits of Automation
- Efficient Task Execution: You can schedule and execute tasks asynchronously, enabling your application to handle time-consuming operations without blocking the user interface. By leveraging automation, you can offload heavy tasks to background processes, ensuring a smooth user experience.
- Scalability: You can scale your application by processing tasks in parallel. You can distribute workloads across multiple instances or nodes, enhancing your application's performance and accommodating increased user demand.
- Workflow Automation: Automate complex business workflow. For example, you can automate content publishing processes, user onboarding tasks, or notifications based on specific events. This improves efficiency and reduces manual effort in managing various aspects of your application.
- Time Savings and Increase Productivity: Save time and reduces repetitive manual work. This allows developers and administrators to focus on more strategic and value-added activities, ultimately increasing productivity and freeing up resources for other tasks.
doExecute (Automation in Liferay)
To use the `doExecute` method in Liferay's Dispatcher interface, you need to follow these steps:
public class MyTaskExecutor extends BaseDispatchTaskExecutor {
/**
* overiding the doExecute method
*/
@Override
public void doExecute(
DispatchTrigger dispatchTrigger,
DispatchTaskExecutorOutput dispatchTaskExecutorOutput)
throws IOException, PortalException {
//implement you task execution logic here
//this method will be called when the scheduled trigger is activated
//you can perform your desired tasks or invoke other methods or services
2. Configure the MyTaskExecutor properties: In the component annotation of the MyTaskExecutor class, you can specify the properties for scheduling the task.
@Component(
immediate = true,
property = {
"dispatch.task.executor.name=“+”TaskExecutor”,
"dispatch.task.executor.type="+” TaskExecutor “
},
service = DispatchTaskExecutor.class
)
USE JOB SCHEDULAR OR MESSAGE LISTENER
Job Scheduler tasks are more flexible than jobs scheduled using MessageListener, because you can make changes to the tasks at runtime through the Job Scheduler UI. Changes to MessageListener jobs must be coded, compiled, and redeployed. The Job Scheduler UI also provides a more complete overview of each Job Scheduler task’s execution properties (e.g., Cron expression, start/end date, cluster mode) and execution history. This information is not provided in the UI for MessageListener jobs.
Configure Scheduler

Within the Dispatch interface, you'll have various options and functionalities to manage and execute tasks.

