Hi Gert,
Yes, I need a way to start a new scheduler or update an existing scheduler's
fire properties dynamically?
Please suggest how do I create the unit test you mentioned?
rgds
subh
Gert Vanthienen wrote:
>
> subh,
>
> I don't think you can do that by merely changing the <timer> message you
> receive, you probably need to access the scheduler inside the
> component. If you could clarify what you want in a unit test, we might
> be able to add the requested behavior. We could e.g. make a new
> endpoint that can receive <schedule> messages to start a new scheduler
> more dynamically. Is this what you are looking for?
>
> Regards,
>
> Gert
>
> subh wrote:
>> Hi Gert,
>>
>> Actually even after my re-scheduling, the original trigger fires and
>> after
>> that none gets fired. As in DefaultQuartzMarshaller, I add the following
>> in
>> my CustomMarshaller class
>>
>> Document document = getTransformer().createDocument();
>> Element root = document.createElement("timer");
>> document.appendChild(root);
>> DOMUtil.addChildElement(root, "name",
>> context.getTrigger().getName());
>> DOMUtil.addChildElement(root, "group",
>> Scheduler.DEFAULT_GROUP);
>> DOMUtil.addChildElement(root, "fullname", jobName);
>> DOMUtil.addChildElement(root, "description",
>> context.getTrigger().getDescription());
>> DOMUtil.addChildElement(root, "fireTime", startDate);
>> DOMUtil.addChildElement(root, "nextFireTime", new
>> Date(startDate.getTime() + 300*1000));
>> message.setContent(new DOMSource(document));
>>
>> I added the "nextFireTime" property, and my message shows
>>
>> DEBUG - SedaQueue -
>> [EMAIL PROTECTED] dequeued
>> exchange: InOnly[
>> id: ID:10.30.9.159-11d5353726d-16:3
>> status: Active
>> role: provider
>> service: {http://com.mycompany.esb/moextract}moeExtractSvc
>> endpoint: endpoint
>> in: <?xml version="1.0" encoding="UTF-8"?><timer><name>(inner
>> bean)</name><group>DEFAULT</group><fullname>DEFAULT.{http://com.mycompany.esb}moeQuartzScheduler:mo
>> eqrtzSchEndpoint</fullname><description/><fireTime>Fri Oct 31 10:22:11
>> CDT
>> 2008</fireTime><nextFireTime>Fri Oct 31 10:22:41 CDT
>> 2008</nextFireTime></timer>
>> ]
>>
>> But still, the quartz component doesnot fire at the above scheduled
>> <nextFireTime/>.
>>
>> rgds
>> subh
>>
>>
>> Gert Vanthienen wrote:
>>
>>> 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-tp20255573p20324809.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.