task scheduling with specific period

45 views
Skip to first unread message

jihad mejdoub

unread,
Apr 8, 2015, 5:21:20 PM4/8/15
to wisdom-...@googlegroups.com
Hi all,

I want to schedule my task every monday at 8:00 ! wisdom allow cron expressions or i must use third-party library such as Quartz ?

thanks

Pellerin Romain

unread,
Apr 8, 2015, 6:09:29 PM4/8/15
to wisdom-...@googlegroups.com
Hi Jihad, 

Quartz is available as an OSGi bundle on Maven Central: http://search.maven.org/#search%7Cga%7C1%7Cquartz%20scheduler

I think you should use it in your app by adding a dependency in your pom.xml.

Best,

--




Romain Pellerin | Founder - CEO

1 rue Fleming - 17000 La Rochelle | www.ubidreams.com


Phone (France): +33 (0) 516 490 484 (office) |  +33 (0) 689 289 580 (mobile) 

Phone (US): +1 (415) 680 4311 (mobile)


Founder & Mentor NANOKO open source project  www.nanoko.org

Blog  | Linkedin | Google+ | Twitter ID Skype: rom1_ubidreams


--
You received this message because you are subscribed to the Google Groups "wisdom-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wisdom-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/wisdom-discuss.
To view this discussion on the web visit https://groups.google.com/d/msgid/wisdom-discuss/dbf65c6f-9fe5-4f64-bf0a-594c6b1069a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

clement escoffier

unread,
Apr 9, 2015, 1:14:03 AM4/9/15
to wisdom-discuss
Hi,

Couple of days ago, I wonder about adding this feature. I still did not make a decision. Fixed time scheduled like you want exhibits a couple of issues:

* obviously the time zones - the server does not necessary have the same time zone as you, so it can lead to unexpected behavior
* dynamism - imagine that the task needs to be executed every day at 8, but a 7:59 it becomes invalid (a requiring service becomes unavailable), and become valid again at 8:01. do you need to execute the task ? So do you consider "close" missed occurrences as "has to be executed ASAP" ?

If we ignore those two issues, we could use jcron parser and bind it to the Wisdom thread pool. 

Cheers,

Clement


--

jihad mejdoub

unread,
Apr 9, 2015, 5:00:59 PM4/9/15
to wisdom-...@googlegroups.com, romain....@ubidreams.com
Hi Romain, 
Thank you for your reply, i hesitate betwen use Quartz and use ScheduledExecutorService  with java 8 and new DateTime API.

Cheers,

jihad mejdoub

unread,
Apr 9, 2015, 5:29:45 PM4/9/15
to wisdom-...@googlegroups.com
Hi Clément,

About your first issue, it's not a real problem for me ;) I will ensure to have the right time zone.
On the other side the second one is a real problem ! indeed, missed occurences must be considered as "has to be executed ASAP". although Quartz handles misfire events with these instructions:

MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY
MISFIRE_INSTRUCTION_DO_NOTHING
MISFIRE_INSTRUCTION_FIRE_NOW
My choice will go to FIRE_NOW instruction. 
What do you think about using Quartz inside controllers ? 

Thanks

clement escoffier

unread,
Apr 10, 2015, 1:26:28 AM4/10/15
to wisdom-discuss, Romain Pellerin
Hi,

2015-04-09 23:00 GMT+02:00 jihad mejdoub <mej...@gmail.com>:
Hi Romain, 
Thank you for your reply, i hesitate betwen use Quartz and use ScheduledExecutorService  with java 8 and new DateTime API.


If you plan to use ScheduledExecutorService, you should have a look to the Wisdom Thread Pools: http://wisdom-framework.org/reference/0.8.0/index.html#_using_wisdom_executors.

Cheers,

Clement
 

clement escoffier

unread,
Apr 10, 2015, 1:27:49 AM4/10/15
to wisdom-discuss
Hi,

2015-04-09 23:29 GMT+02:00 jihad mejdoub <mej...@gmail.com>:
Hi Clément,

About your first issue, it's not a real problem for me ;) I will ensure to have the right time zone.
On the other side the second one is a real problem ! indeed, missed occurences must be considered as "has to be executed ASAP". although Quartz handles misfire events with these instructions:

MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY
MISFIRE_INSTRUCTION_DO_NOTHING
MISFIRE_INSTRUCTION_FIRE_NOW
My choice will go to FIRE_NOW instruction. 

That's nice, didn't know that. However, not sure it handle the same type of 'miss'. 
 
What do you think about using Quartz inside controllers ? 

Inside controller definitely no, inside a service responsible for task scheduling, yes. Can you hook you own executor service in Quartz ?

Cheers,

Clement
 

Thanks


Le jeudi 9 avril 2015 07:14:03 UTC+2, clement escoffier a écrit :
Hi,

Couple of days ago, I wonder about adding this feature. I still did not make a decision. Fixed time scheduled like you want exhibits a couple of issues:

* obviously the time zones - the server does not necessary have the same time zone as you, so it can lead to unexpected behavior
* dynamism - imagine that the task needs to be executed every day at 8, but a 7:59 it becomes invalid (a requiring service becomes unavailable), and become valid again at 8:01. do you need to execute the task ? So do you consider "close" missed occurrences as "has to be executed ASAP" ?

If we ignore those two issues, we could use jcron parser and bind it to the Wisdom thread pool. 

Cheers,

Clement


2015-04-08 23:21 GMT+02:00 jihad mejdoub <mej...@gmail.com>:
Hi all,

I want to schedule my task every monday at 8:00 ! wisdom allow cron expressions or i must use third-party library such as Quartz ?

thanks

--
You received this message because you are subscribed to the Google Groups "wisdom-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wisdom-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/wisdom-discuss.
To view this discussion on the web visit https://groups.google.com/d/msgid/wisdom-discuss/dbf65c6f-9fe5-4f64-bf0a-594c6b1069a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wisdom-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wisdom-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/wisdom-discuss.

jihad mejdoub

unread,
Apr 11, 2015, 5:39:33 AM4/11/15
to wisdom-...@googlegroups.com
Hi Clément,

Thank you for your detailed advice. I will try to implement this with Quartz, and I will let you know as soon as possible.

Best regards

jihad mejdoub

unread,
Apr 19, 2015, 11:51:33 AM4/19/15
to wisdom-...@googlegroups.com
Hi all,

I'm starting to implement my own tasks scheduler with Quartz. But I have a following log error : 

18:09:13.721 4308 [main] ERROR o.o.c.c.activators.BundleDeployer - Error during the starting of fr.astek.penseAsteKroissants.core
org.osgi.framework.BundleException: Unresolved constraint in bundle fr.astek.penseAsteKroissants.core [61]: Unable to resolve 61.0: missing requirement [61.0] osgi.wiring.package; (&(osgi.wiring.package=org.quartz.impl)(version>=2.2.0)(!(version>=3.0.0))) [caused by: Unable to resolve 66.0: missing requirement [66.0] osgi.wiring.package; (osgi.wiring.package=com.mchange.v2.c3p0)]
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4002) [chameleon-core-1.10.6.jar:na]
at org.apache.felix.framework.Felix.startBundle(Felix.java:2045) [chameleon-core-1.10.6.jar:na]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:976) ~[org.apache.felix.framework-4.4.1.jar:na]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:963) ~[org.apache.felix.framework-4.4.1.jar:na]
at org.ow2.chameleon.core.activators.BundleDeployer.open(BundleDeployer.java:192) [chameleon-core-1.10.6.jar:na]
at org.ow2.chameleon.core.activators.DirectoryMonitor.addingService(DirectoryMonitor.java:238) [chameleon-core-1.10.6.jar:na]
at org.ow2.chameleon.core.activators.DirectoryMonitor.addingService(DirectoryMonitor.java:52) [chameleon-core-1.10.6.jar:na]
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:932) [org.apache.felix.framework-4.4.1.jar:na]
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:864) [org.apache.felix.framework-4.4.1.jar:na]
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) [org.apache.felix.framework-4.4.1.jar:na]
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) [org.apache.felix.framework-4.4.1.jar:na]
at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:894) [org.apache.felix.framework-4.4.1.jar:na]
at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:943) [chameleon-core-1.10.6.jar:na]
at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:794) [chameleon-core-1.10.6.jar:na]
at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:544) [chameleon-core-1.10.6.jar:na]
at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4445) [chameleon-core-1.10.6.jar:na]
at org.apache.felix.framework.Felix.registerService(Felix.java:3431) [chameleon-core-1.10.6.jar:na]
at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:346) [chameleon-core-1.10.6.jar:na]
at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:353) [chameleon-core-1.10.6.jar:na]
at org.ow2.chameleon.core.activators.BundleDeployer.start(BundleDeployer.java:80) [chameleon-core-1.10.6.jar:na]
at org.ow2.chameleon.core.utils.FrameworkManager.start(FrameworkManager.java:117) [chameleon-core-1.10.6.jar:na]
at org.ow2.chameleon.core.Chameleon.start(Chameleon.java:257) [chameleon-core-1.10.6.jar:na]
at org.ow2.chameleon.core.Main.main(Main.java:70) [chameleon-core-1.10.6.jar:na]
18:09:13.801 4388 [main] ERROR o.o.c.c.activators.BundleDeployer - Error during the starting of org.quartz-scheduler.quartz
org.osgi.framework.BundleException: Unresolved constraint in bundle org.quartz-scheduler.quartz [66]: Unable to resolve 66.0: missing requirement [66.0] osgi.wiring.package; (osgi.wiring.package=com.mchange.v2.c3p0)
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4002) [chameleon-core-1.10.6.jar:na]
at org.apache.felix.framework.Felix.startBundle(Felix.java:2045) [chameleon-core-1.10.6.jar:na]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:976) ~[org.apache.felix.framework-4.4.1.jar:na]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:963) ~[org.apache.felix.framework-4.4.1.jar:na]
at org.ow2.chameleon.core.activators.BundleDeployer.open(BundleDeployer.java:192) [chameleon-core-1.10.6.jar:na]
at org.ow2.chameleon.core.activators.DirectoryMonitor.addingService(DirectoryMonitor.java:238) [chameleon-core-1.10.6.jar:na]
at org.ow2.chameleon.core.activators.DirectoryMonitor.addingService(DirectoryMonitor.java:52) [chameleon-core-1.10.6.jar:na]
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:932) [org.apache.felix.framework-4.4.1.jar:na]
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:864) [org.apache.felix.framework-4.4.1.jar:na]
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) [org.apache.felix.framework-4.4.1.jar:na]
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) [org.apache.felix.framework-4.4.1.jar:na]
at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:894) [org.apache.felix.framework-4.4.1.jar:na]
at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:943) [chameleon-core-1.10.6.jar:na]
at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:794) [chameleon-core-1.10.6.jar:na]
at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:544) [chameleon-core-1.10.6.jar:na]
at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4445) [chameleon-core-1.10.6.jar:na]
at org.apache.felix.framework.Felix.registerService(Felix.java:3431) [chameleon-core-1.10.6.jar:na]
at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:346) [chameleon-core-1.10.6.jar:na]
at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:353) [chameleon-core-1.10.6.jar:na]
at org.ow2.chameleon.core.activators.BundleDeployer.start(BundleDeployer.java:80) [chameleon-core-1.10.6.jar:na]
at org.ow2.chameleon.core.utils.FrameworkManager.start(FrameworkManager.java:117) [chameleon-core-1.10.6.jar:na]
at org.ow2.chameleon.core.Chameleon.start(Chameleon.java:257) [chameleon-core-1.10.6.jar:na]
at org.ow2.chameleon.core.Main.main(Main.java:70) [chameleon-core-1.10.6.jar:na]

After some google researches, the component c3p0 adds the JDBC driver imports. but since I choose MongoDB as web application DB, I will store quartz jobs with  quartz-mongodb, so how can I exclude this package from my app ?

N.B: I tried with BND but with no success :(  

clement escoffier

unread,
Apr 19, 2015, 12:10:34 PM4/19/15
to wisdom-discuss
Hi,

In the osgi.bnd file, try to add in the `Import-Package` clause:

com.mchange*;resolution:=optional

So it would be something like:

Import-Package: com.mchange*;resolution:=optional, *

Let me know

Clement

jihad mejdoub

unread,
Apr 19, 2015, 1:07:44 PM4/19/15
to wisdom-...@googlegroups.com
Hi Clément,

Thank you for your quick reply.
I tried your instruction but I still have the same problem :( . Indeed this instruction is ignored for some reason !
[WARNING] Unused Import-Package instructions: [com.mchange*]

clement escoffier

unread,
Apr 19, 2015, 1:54:13 PM4/19/15
to wisdom-discuss
Oh, sorry I miss read the error message:

18:09:13.721 4308 [main] ERROR o.o.c.c.activators.BundleDeployer - Error during the starting of fr.astek.penseAsteKroissants.core
org.osgi.framework.BundleException: Unresolved constraint in bundle fr.astek.penseAsteKroissants.core [61]: Unable to resolve 61.0: missing requirement [61.0] osgi.wiring.package; (&(osgi.wiring.package=org.quartz.impl)(version>=2.2.0)(!(version>=3.0.0))) [caused by: Unable to resolve 66.0: missing requirement [66.0] osgi.wiring.package; (osgi.wiring.package=com.mchange.v2.c3p0)]


Mrinmoy Aich

unread,
Aug 25, 2016, 1:32:36 AM8/25/16
to wisdom-discuss
Hi Jihad,
     Have you fixed the issue? We are facing the same issue in our project but unable to resolve. Please share your fix details if you have any.

Thnaks & Regards
Mrinmoy Aich 
Reply all
Reply to author
Forward
0 new messages