• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dynamically adding/removing task in Scheduled Task

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have configured scheduled tasks as follows in context xml and working as expected.



Is it possible to disable/remove this cron task at Runtime ?
as well is it possible to add another cron/fixed Interval/Fixed Delay tasks at runtime ?

If Yes can somebody tell me How.

Thanks and warm Regards.

Raja Patil
 
Ranch Hand
Posts: 49
1
Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should be able to add / remove if you get hold of the instances of ScheduledTaskManager (there must be some sort of manager :-)), from java code.

what API are you using?
 
raja patil
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Thanks krishna kanth for quick response,

krishna kanth wrote:You should be able to add / remove if you get hold of the instances of ScheduledTaskManager (there must be some sort of manager :-)), from java code.

what API are you using?



I am using java for services and from the service I would like to access The ScheduledTaskManager bean and add/remove/disable tasks.
The required Parameters like Task Name, cron string and whether to add/remove/disable will be passed to the service.

I would like to know how to get hold of ScheduledTaskManager bean which is instantiated by xml config (refer my original post) and what class it is, so that I can refer the spring docs and do needful depending upon methods and properties available on that class.

BTW I use eclipse as IDE for development.


Thanks and warm regards.

Raja Patil
 
Krishna Kanth
Ranch Hand
Posts: 49
1
Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try reading about BeanNameAware and BeanFactoryAware. ( assuming its a spring bean you are talking about ). these interface let spring interact with your java class and help your java class retrieve a bean instance.
 
Krishna Kanth
Ranch Hand
Posts: 49
1
Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Would be something like this

Pseudo Code:
 
raja patil
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Krishna Kanth,

Can you guide me about how can I pass bean defined with following statement as Constructor Argument to Another Bean.

<task:scheduled-tasks scheduler="taskScheduler">

I tried Passing it as "taskSchedular" but a exception is Raised. I also tried to put id="mySchedular" but attribute id is Not Allowed.

Thanks and warm regards

Raja Patil
 
Krishna Kanth
Ranch Hand
Posts: 49
1
Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
https://jira.springsource.org/browse/INT-449

There are now a few options for accessing the TaskScheduler:
1) manual bean lookup with the constant: springBeanFactory.getBean( IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME )
2) convenient static lookup methods:
a) IntegrationContextUtils.getTaskScheduler(beanFactory);
b) IntegrationContextUtils.getRequiredTaskScheduler(beanFactory);
3) extend IntegrationObjectSupport which provides a protected getTaskScheduler() method (intended only for framework code).

Let me know if it does not work. I have used bean factory aware earlier, but can try bean name aware as well.

I am assuming you figured out way to add / remove jobs once you get hold of scheduler bean.
 
reply
    Bookmark Topic Watch Topic
  • New Topic