Fórumok

Need read cron-trigger-value value from portal-ext.properties

venkatesan shanmugasundaram, módosítva 9 év-val korábban

Need read cron-trigger-value value from portal-ext.properties

New Member Bejegyzések: 2 Csatlakozás dátuma: 2014.10.29. Legújabb bejegyzések
HI,

I want read "<cron-trigger-value>" value from portal-ext.properties.
Could please let me know is it possible read from portal-ext instead of liferay-portlet.xml.

<cron-trigger-value>0 40 18 ? * MON,WED *</cron-trigger-value>

Thanks,
Venkat
thumbnail
Tanweer Ahmed ., módosítva 1 év-val korábban

RE: Need read cron-trigger-value value from portal-ext.properties

Expert Bejegyzések: 322 Csatlakozás dátuma: 2010.03.11. Legújabb bejegyzések
Hi Venkatesan,

The easiest and recommended way to create a Scheduler is to define the values in liferay-portlet.xml.

In case you still want to do it with portal-ext.properties, you will have to write extra piece of code.

Read the value from portal-ext.properties and pass it as parameter to setTriggerValue().The code must be written in the init() of Portlet so that the scheduler is registered during the initialization of Portlet.

Refer the sample code below:
SchedulerEntry schedulerEntry = new SchedulerEntryImpl();
schedulerEntry.setTriggerValue("pass-the-cron-trigger-value-from-portal-ext-here");
SchedulerEngineHelperUtil.schedule(schedulerEntry, StorageType.MEMORY_CLUSTERED, portletId, 0);


Regards,
Tanweer.
thumbnail
Andew Jardine, módosítva 9 év-val korábban

RE: Need read cron-trigger-value value from portal-ext.properties

Liferay Legend Bejegyzések: 2416 Csatlakozás dátuma: 2010.12.22. Legújabb bejegyzések
You can read anything out of the portal-ext.properties file using the PropsUtil or PrefsPropsUtil classes. It would not be defined as <cron-trigger-value> though.. or at least it shouldn't be, more likely it would be cron.trigger.value= ... but you should probably be a little more explicit and use <plugin.name>.cron.trigger.value.

As Tanweer says though, that property won't be configured as part of your scheduler definition so you would need to write some additional code to ensure that it's value is updated. Alternatively, you could create the scheduled job programatically using the Liferay API and read the values you want to use for the job from the portal-ext while it is being built. I have done this in the past. Note though, I haven't tried with newer versions, but in 6.1.1 I had an issue where scheduled jobs created using the API were not working properly in a clustered environment.
venkatesan shanmugasundaram, módosítva 9 év-val korábban

RE: Need read cron-trigger-value value from portal-ext.properties

New Member Bejegyzések: 2 Csatlakozás dátuma: 2014.10.29. Legújabb bejegyzések
Thanks for prompt reply to Andew and Tanweer. I'll decide which approach needs to take.