L.S.,
Inside ServiceMix, there's nothing that prohibits you from using the
Scheduler object to schedule a new job, so I guess it should be possible
somehow. Are you sure you aren't showing the data from the original trigger
at the time it is being fired, because it would be normal that the
nextFireTime is null (since you are only rescheduling it after it has been
fired) at that point in time? Could you add some logging after you're done
rescheduling to see what the effect is at that point.
Regards,
Gert
subh wrote:
>
> Hi,
>
> Is it possible to reschedule a quartz trigger? I have defined my Simple
> trigger as follows
>
> XBEAN:
> ======
> <quartz:endpoint service="esb:moeQuartzScheduler"
> endpoint="moeqrtzSchEndpoint"
> targetService="moeextract:moeExtractSvc">
>
> <quartz:trigger>
> <quartz:simple repeatCount="0" repeatInterval="10000" />
> </quartz:trigger>
>
> <quartz:marshaler>
> <bean class="com.esb.quartz.scheduler.CustomQuartzMarshaler" />
> </quartz:marshaler>
>
> </quartz:endpoint>
>
> In my custom marshaller I extended extends DefaultQuartzMarshaler and
> added the following code to reschedule the job, but it doesnot work and
> shows the 'nextFireTime' as NULL.
>
> Am I doing it right? Can it be done in servicemix?
>
> CODE:
> ======
> public void populateNormalizedMessage(NormalizedMessage message,
> JobExecutionContext context) throws JobExecutionException,
> MessagingException {
> super.populateNormalizedMessage(message, context);
> String fireTime = "<JobFireTime>" + context.getScheduledFireTime()
> + "</JobFireTime>";
> try {
> //context.getScheduler().shutdown();
>
> Scheduler sched = context.getScheduler();
> //Scheduler sched = StdSchedulerFactory.getDefaultScheduler();
>
> Date startDate = new java.util.Date();
> long runEveryInMilliseconds = 900*1000; // every 15 minutes
> String jobName = context.getTrigger().getFullJobName();
>
> //SimpleTrigger trigger = new SimpleTrigger(jobName,
> Scheduler.DEFAULT_GROUP, startDate, null,
> SimpleTrigger.REPEAT_INDEFINITELY, runEveryInMilliseconds);
>
> SimpleTrigger trigger = (SimpleTrigger)context.getTrigger();
> trigger.setGroup(Scheduler.DEFAULT_GROUP);
> trigger.setStartTime(startDate);
> trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
> trigger.setRepeatInterval(runEveryInMilliseconds);
> trigger.setJobName(jobName);
> trigger.setJobGroup(Scheduler.DEFAULT_GROUP);
> sched.rescheduleJob(jobName, Scheduler.DEFAULT_GROUP, trigger);
> }
> catch (SchedulerException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> message.setContent(new StringSource(fireTime));
> }
>
>
> CONSOLE:
> ========
>
> 14:59:04,283 | DEBUG | DefaultQuartzScheduler_Worker-7 | QuartzComponent
>
> | rvicemix.quartz.QuartzEndpoint 134 | Firing Quartz Job with context:
> JobExecutionContext: trigger: 'DEFAULT.(inner bean) job:
> DEFAULT.{http://com.mycompany.esb}moeQuartzScheduler:moeqrtzSchEndpoint
> fireTime: 'Thu Oct 30 14:59:04 CDT 2008 scheduledFireTime: Thu Oct 30
> 14:59:02 CDT 2008 previousFireTime: 'null nextFireTime: null isRecovering:
> false refireCount: 0
>
>
>
-----
---
Gert Vanthienen
http://gertvanthienen.blogspot.com
--
View this message in context:
http://www.nabble.com/Re-scheduling-a-servicemix-quartz-trigger-tp20255573p20256504.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.