The custom scheduler is not working after upgrading from 7.4 U62 to U90
How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!
While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.
Legacy Article
You are viewing an article from our legacy "FastTrack"
publication program, made available for informational purposes. Articles
in this program were published without a requirement for independent
editing or verification and are provided"as is" without
guarantee.
Before using any information from this article, independently verify its
suitability for your situation and project.
Issue
- We have written a scheduler which works perfectly in 7.4 U62, but when we updated our bundle to 7.4 U90, it is not working.
Resolution
- Due to the changes by LPS-176754, please adapt your code to make it work in 7.4 U90. Below is a guideline you can refer when adapting the code. As this involves customization, what Liferay Support can help is limited. Please feel free to contact your Sales Representative for further assistance from Liferay Global Services team.
-
- You can compare the previous code to the current one and make necessary changes.
- Previous code
- Current code
2. How to replace your xxxMessageListener.java with an xxxSchedulerJobConfiguration.java
Step 1 - Copy the old file
Copy the xxxMessageListener.java file into xxx/internal/scheduler folder
For example, SyncMaintenanceMessageListener.java would move from com/liferay/sync/internal/messaging/ to com/liferay/sync/internal/scheduler/
Step 2 - Rename the old file
Rename the xxxMessageListener.java file to xxxSchedulerJobConfiguration.java
For example SyncMaintenanceMessageListener.java to SyncMaintenanceSchedulerJobConfiguration.java
Step 3 - Change the package in the file
package com.liferay.xxx.internal.messaging; changes to package com.liferay.xxx.internal.scheduler;
For example, package com.liferay.sync.internal.messaging; to package com.liferay.sync.internal.scheduler;
Step 4 - Add the @Component annotation
Remove the old annotation. Add the new one:
@Component(service = SchedulerJobConfiguration.class)
Step 5 - Import and Implement the SchedulerJobConfiguration interface
Add the import com.liferay.portal.kernel.scheduler.SchedulerJobConfiguration; line
Your xxxSchedulerJobConfiguration implements SchedulerJobConfiguration
For example, public class SyncMaintenanceSchedulerJobConfiguration
implements SchedulerJobConfiguration {
Step 6 - Override UnsafeRunnable
Import the class:
import com.liferay.petra.function.UnsafeRunnable;
Override the method:
@Override
public UnsafeRunnable<Exception> getJobExecutor() {
Step 7 - Override TriggerConfiguration
import the class:
import com.liferay.portal.kernel.scheduler.TriggerConfiguration;
Override the method:
@Override
public TriggerConfiguration getTriggerConfiguration() {
Step 8 - Modify the activate method
Modify the method to only include the ConfigurableUtil method. For example:
@Activate
protected void activate(Map<String, Object> properties) {
_assetPublisherWebConfiguration = ConfigurableUtil.createConfigurable(
AssetPublisherWebConfiguration.class, properties);
}
Step 9 - Remove the unused classes and their imports
import com.liferay.portal.kernel.messaging.BaseMessageListener;
import com.liferay.portal.kernel.messaging.DestinationNames;
import com.liferay.portal.kernel.messaging.Message;
import com.liferay.portal.kernel.scheduler.SchedulerEngineHelper;
import com.liferay.portal.kernel.scheduler.SchedulerEntry;
import com.liferay.portal.kernel.scheduler.SchedulerEntryImpl;
import com.liferay.portal.kernel.scheduler.Trigger;
import com.liferay.portal.kernel.scheduler.TriggerFactory;
Step 10 - Delete the xxxMessageListener.java file
Did this article resolve your issue ?