The custom scheduler is not working after upgrading from 7.4 U62 to U90

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.
    1. 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
     

 

 

 

¿Fue útil este artículo?
Usuarios a los que les pareció útil: 0 de 1