Reputation: 2760
I have a situation where I need to check the profile maven is running on and then according to that I need to configure task scheduler. There are two profiles one is 'global' and the other one is 'nonglobal', what I did is:
<task:scheduler id="customerPortalTaskScheduler" pool-size="1" />
<task:scheduled-tasks scheduler="customerPortalTaskScheduler">
<task:scheduled ref="SubscriptionService" method="updateNextDistributionDateForAllCurrentUsers" cron="${nhst.ncp.instance} == 'global' ? #{customerportal['globalUpdateDistributionDateServiceTuesday.CronTrigger']} : #{customerportal['updateDistributionDateServiceMondayThursday.CronTrigger']}" />
<task:scheduled ref="SubscriptionService" method="updateNextDistributionDateForAllCurrentUsers" cron="${nhst.ncp.instance} == 'global' ? #{customerportal['globalUpdateDistributionDateServiceWednesday.CronTrigger']} : #{customerportal['updateDistributionDateServiceFriday.CronTrigger']}" />
<task:scheduled ref="SubscriptionService" method="updateNextDistributionDateForAllCurrentUsers" cron="${nhst.ncp.instance} == 'global' ? #{customerportal['globalUpdateDistributionDateServiceThursday.CronTrigger']} : #{customerportal['updateDistributionDateServiceWeekend.CronTrigger']}" />
</task:scheduled-tasks>
${nhst.ncp.instance} is instance of maven profile. It would say whether its global or nonglobal profile. It does work fine, because properties file are being loaded properly.
With the above configuration, I am getting an error which is there in screenshot.
Any ideas how to solve this?
Upvotes: 0
Views: 875
Reputation: 747
Do not depend on profile activated. Depend on local configuration file:
<context:property-placeholder ignore-resource-not-found="true" location="file:/etc/mumbojumbo/app.config.properties"/>
in /etc/mumbojumbo/app.config.properties
cron.schedule = blabla
You can always provide a sensible default value. So you only have to override it where you want.
<task:scheduled ref="SubscriptionService" method="updateNextDistributionDateForAllCurrentUsers" cron="${cron.schedule:defaultvalue}" />
Something like that?
Upvotes: 2