Liferay 7: Scheduler Manager Gogo Shell Commands
For the development of a project based on Liferay 7, I had to create a module for job management. Scheduler Manager Gogo Shell Commands implements a set of Gogo Shell commands that handle Liferay jobs. The tasks you can perform are:
- list: List of the all Jobs filtered by state (default ALL)
- info: Print detail info of the job
- pause: Pause one or more Jobs by Job Name, Group Name and Storage Type
- resume: Resume one or more Jobs by Job Name, Group Name and Storage Type
If you are impatient you can immediately download the bundle from the repository GitHub and install it on your Liferay instance.
Scheduler Manager #GogoShell Commands @Liferay plugin for handle #liferay jobsClick To TweetThe version 1.3.0 of this project was tested on Liferay 7.2.0 Community Edition GA1
1. Getting Started
To start testing the plugin you need:
- clone this repository
- build project
- deploy OSGi module (it.dontesta.labs.liferay.gogo.scheduler.manager-$version.jar)
$ git clone https://github.com/amusarra/scheduler-manager-gogoshell-command.git $ cd scheduler-manager-gogoshell-command $ ./gradlew clean build
The last gradle command, create a OSGi bundle that you must deploy on your Liferay instance. You can deploy with this command (replace auto deploy directory with your).
$ cp build/libs/it.dontesta.labs.liferay.gogo.scheduler.manager-1.3.0.jar /opt/liferay-ce-portal-7.2.0-ga1/deploy/
You could deploy also with the deploy gradle task, but must setting the auto.deploy.dir in gradle.properties file.
$ ./gradlew deploy
2. After deploy bundle
After the deploy of the bundle you can check if the bundle is correctly installed. Connect to Gogo Shell via telnet and execute lb command.
$ telnet localhost 11311 g! lb|grep Scheduler 1075|Active | 10|Scheduler Manager Gogo Shell Command (1.3.0)|1.3.0
Well done! The bundle is in state ACTIVE.
3. How to use commands
Via Gogo Shell we check deployed commands (that have scheduler as scope) via completion.
g! osgi> scheduler: scheduler:info scheduler:jobIsFired scheduler:jobsIsFired scheduler:list scheduler:listJobsInProgress scheduler:pause scheduler:resume
The list of commands obtained are those described at the beginning. You can see for each command the usage, by this command (help scope:commandName). Follow the help of the four available commands.
g! help scheduler:info info - Detail info of the job scope: scheduler parameters: String The JobName String The GroupName String The StorageType {MEMORY, MEMORY_CLUSTERED, PERSISTED}
The storage types are defined in StorageType
g! help scheduler:list list - List of the all Jobs filtered by state (default ALL) scope: scheduler options: --status, -s Filter the jobs by trigger state {state: COMPLETE,NORMAL,EXPIRED,PAUSED,UNSCHEDULED} [optional]
The states of the trigger defined in TriggerState Enumeration
g! help scheduler:pause pause - Pause one or more Jobs by Job Name, Group Name and Storage Type scope: scheduler parameters: String The JobName String The GroupName String The StorageType {MEMORY, MEMORY_CLUSTERED, PERSISTED}
g! help scheduler:resume resume - Resume one or more Jobs by Job Name, Group Name and Storage Type scope: scheduler parameters: String The JobName String The GroupName String The StorageType {MEMORY, MEMORY_CLUSTERED, PERSISTED}
3.1 Scheduler List
g! scheduler:list
g! scheduler:list --status PAUSED
3.2 Scheduler Pause and Resume
g! scheduler:pause com.liferay.asset.publisher.web.internal.messaging.CheckAssetEntryMessageListener com.liferay.asset.publisher.web.internal.messaging.CheckAssetEntryMessageListener MEMORY_CLUSTERED
g! scheduler:resume com.liferay.asset.publisher.web.internal.messaging.CheckAssetEntryMessageListener com.liferay.asset.publisher.web.internal.messaging.CheckAssetEntryMessageListener MEMORY_CLUSTERED
3.3 Scheduler Info
g! scheduler:info com.liferay.asset.publisher.web.internal.messaging.CheckAssetEntryMessageListener com.liferay.asset.publisher.web.internal.messaging.CheckAssetEntryMessageListener MEMORY_CLUSTERED
This command (compared to the list of jobs) shows additional information:
- Cron Expression
- Destination Name
- Job Exceptions
4. Resources
- Liferay 7 CE/Liferay DXP Scheduled Task post by David H Nebinger (on Liferay Blog)
- Scheduler Example on my GitHub account
- How to implement a custom Gogo shell command for Liferay 7 post by Marco Napolitano