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.
Environment
- Liferay DXP 7.4
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 yourxxxMessageListener.java
with anxxxSchedulerJobConfiguration.java
Step 1 - Copy the old file
Copy thexxxMessageListener.java
file intoxxx/internal/scheduler
folder
For example,SyncMaintenanceMessageListener.java
would move fromcom/liferay/sync/internal/messaging/
tocom/liferay/sync/internal/scheduler/
Step 2 - Rename the old file
Rename thexxxMessageListener.java
file toxxxSchedulerJobConfiguration.java
For exampleSyncMaintenanceMessageListener.java
toSyncMaintenanceSchedulerJobConfiguration.java
Step 3 - Change the package in the filepackage com.liferay.xxx.internal.messaging;
changes topackage com.liferay.xxx.internal.scheduler;
For example,package com.liferay.sync.internal.messaging;
topackage 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 theimport com.liferay.portal.kernel.scheduler.SchedulerJobConfiguration;
line
YourxxxSchedulerJobConfiguration
implementsSchedulerJobConfiguration
For example,public class SyncMaintenanceSchedulerJobConfiguration
implements SchedulerJobConfiguration {
Step 6 - OverrideUnsafeRunnable
Import the class:import com.liferay.petra.function.UnsafeRunnable;
Override the method:@Override
public UnsafeRunnable<Exception> getJobExecutor() {
Step 7 - OverrideTriggerConfiguration
import the class:import com.liferay.portal.kernel.scheduler.TriggerConfiguration;
Override the method:@Override
public TriggerConfiguration getTriggerConfiguration() {
Step 8 - Modify theactivate
method
Modify the method to only include theConfigurableUtil
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 importsimport 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 thexxxMessageListener.java
file
Contenido exclusivo para suscriptores.
Una Suscripción Enterprise de Liferay proporciona acceso a más de 1.500 artículos que incluyen las mejores practicas, diagnóstico de problemas y otras soluciones útiles. Inicia sesión para tener un acceso completo.
Inicia sesión