[jboss-user] [jBPM Users] - Re: How to use timers?
Thank you Martin, you actually helped me and I got it to work!! I'm going to summarize it up because I think that certain things are not so intuitive for a "jBPM scheduler"-newbie like me. First of all, the default implementation of the scheduler service, provided by jBPM, is DbSchedulerServiceFactory, which uses the database to store information about scheduled actions associated with timers. This means that a database is needed even to write a simple JUnit test case that uses timers and this justifies the need to deploy your process definition (it's needed to store the related timers and timer jobs in the database, as well). I would assume that a different scheduler service implementation could be made to avoid the use of a database, however let's talk about the default implementation. Even if a database is needed, there's no need to extend AbstractDbTestCase, which provides many methods to create and clean the schema and to interact with the database. In fact, in the simplest case, jBPM (thanks to Hibernate) will create automatically an in-memory database for you when you go to deploy your process definition and/or schedule a timer action. In this case, however, you should take care of the db lifecycle, however I think (but I may be wrong) that if you destory the jbpmConfiguration (by calling close) the in-memory db will be destroyed too... Anyway, in my case I was running an only test method, so it's not so important how the db is handled between multiple test methods invocations. In my previous example (TRIAL 2) timer actions were correctly saved in the database by the DbSchedulerServiceFactory, but they were not executed because no JobExecutor thread was started. The JobExecutor thread is actually a thread that periodically reads from the database, searching for saved timer actions (jobs) and executes them. So, if I change my test case by calling jbpmConfiguration.startJobExecutor() just after the configuration creation, I make sure that the "scheduler" is started. Actually, I would rather say that there is no scheduler to start, but that the default scheduler service implementation expects that a JobExecutor thread is present to execute timer actions. In other words, the JobExecutor is itself part of the default scheduler service implementation. I think that this only sentence would be enough to say that my original problem is not so stupid as kukeltje says and that the documentation could be drastically improved on this subject (I'm also wondering what is http://docs.jboss.com/jbpm/v3.2/userguide/html_single/#schedulerdeployment all about!?). Anyway, this is not enough, because another action is needed in order to make the JobExecutor run timer actions in my test case: just after the signal invocation, that moves my process instance to the waiting state (with attached timer), I have to close the jBPM context in order to commit things (the deployed process definition, the process instance state and the related saved timers and jobs), otherwise the JobExecutor, which works on another thread, wouldn't find anything to executoe. Having the whole scenario cleared, this sounds reasonable and obvious, but I think it might not be so straight away for a first time user that is writing a simple JUnit test case. Using the AbstractDbTestCase class mentioned by Martin, this would be automatically achieved because the method processJobs(long) does a "commit" before starting the JobExecutor. Thank you again Martin and please correct me if I've written something wrong. Anyway, if this is considered to be a simple answer to a basic question (as kukeltje said)... well, I'm wondering why kukeltje couldn't write it himself: he would have certainly spent much less time that writing his two previous smart posts, as Martin's kind answer demonstrated. View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4267259#4267259 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4267259 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [jBPM Users] - Re: How to use timers?
geez, guys, calm down again ;-) "mauromol" wrote : | I'm writing a test case, I am not running in a web application for now. | In that case, you still need persistence. With the DbSchedulerServiceFactory, timers are stored in the jBPM database and executed by the JobExecutor (which needs to be started, btw). The easiest way to test timers is by extending the AbstractDbTestCase class. Have a look at the processJobs(long maxWait) method, which starts a JobExecutor and waits until jobs are processed: http://anonsvn.jboss.org/repos/jbpm/jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java There are a couple of test cases for timer execution related scenarios, such as this one, for example: http://anonsvn.jboss.org/repos/jbpm/jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm2036/JBPM2036Test.java View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4267247#4267247 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4267247 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [jBPM Users] - Re: How to use timers?
"ardavan" wrote : | Mauromol, make sure you have: | | | | | | in your jbpm.cfg.xml | Thank you ardavan, but this doesn't help, as I've written in my original post. View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4267233#4267233 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4267233 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [jBPM Users] - Re: How to use timers?
Dear kukeltje, I was wondering why you decided to loose your time to answer to my stupid questions without even reading them. However, I should have remembered your kindness and tendency to discussion from my previous experiences some months ago, both in the forum and in JIRA. But as I am too in a really good mood, I will reply. Regarding jBPM documentation: anonymous wrote : | http://docs.jboss.com/jbpm/v3.2/userguide/html_single/#tasktimers | http://docs.jboss.com/jbpm/v3.2/userguide/html_single/#scheduler | http://docs.jboss.com/jbpm/v3.2/userguide/html_single/#timer.element | Is this exhaustive documentation for you? Maybe we have a different idea about the mean of "documentation". Have you ever read the documentation for Spring (that's the first example that comes into my mind)? Have you ever looked at jBPM 3 source code just to seek for some basic Javadoc? How much did you find? anonymous wrote : | http://fisheye.jboss.org/changelog/JbpmSvn/jbpm3/trunk/modules/core/src/test/java/org/jbpm/scheduler/exe?todate=1248416261336 | | etc (including several posts in the forum)... so saying there is no documentation is plain wrong ;-). | This is NOT documentation, these are web pages that talk about problems like mine because there is poor official documentation available! Especially, pointing me to a series of SVN logs saying they are "documentation" is something that really makes me laugh. Before you spend even more time to reply that jBPM is an open source project and that everyone can contribute in either code or documentation, let me say that I can even accept that jBPM has poor documentation, but please at least don't say that my questions are stupid because there is exhaustive documentation available!!! anonymous wrote : | First of all, let me point you to http://catb.org/~esr/faqs/smart-questions.html#volume | It is really frustrating to read these gems of wisdom, especially after I used a http://www.jboss.org/index.html?module=bb&op=viewtopic&t=158610 to post my question and I even followed your "suggestion" to provide a ready to copy-'n'-paste test case. I did that and it is bad... What should I say? anonymous wrote : | anonymous wrote : | | The first problem I encounter is a "service 'scheduler' unavailable" error. Searching on the net I found some hints like "start the scheduler" or "change the configuration in src/main/config/jbpm.cfg.xml. | | | | Isn't the internet great | Yes it is and I use it every day for my work. It is a pity that, in this case, the suggestion given were useless... But you surely missed it, because you were so much happy to start your new controversy that you didn't even try to read and understand my post. anonymous wrote : | anonymous wrote : | | But nobody explains WHAT is the scheduler, | | | | Are you serious? You did not ever get the impression that it is used to execute timers? Strange since you have a problem with timers and a message that the scheduler is unavailable and you started searching in this direction. Oh, and it is in the first chapter of the user docs: http://docs.jboss.org/jbpm/v3/userguide/introduction.html#d0e130 | You're really nice. Of course I know WHAT is a scheduler. I meant: what is jBPM Scheduler? Which classes do implement it? How is it meant to be used especially in my case? Doesn't jBPM start a scheduler by its own if it is needed? How is it related to a multi-threaded environment especially in a JUnit test case? How this then translates to a web application environment? anonymous wrote : | anonymous wrote : | | how to start it, etc.. | | | | Besides in the docs: http://docs.jboss.org/jbpm/v3/userguide/deployment.html#webapplication | I'm writing a test case, I am not running in a web application for now. anonymous wrote : | Very little searching yielded | http://www.jboss.org/index.html?module=bb&op=viewtopic&t=80078&postdays=0&postorder=asc&start=10 | Interesting. So, please, show me where there's explained how to start the scheduler there? Anyway, if you read my post you would have seen that I was able to make the jBPM timer work without starting any scheduler, just by adding a JTA JAR in the classpath, by creating my own jBPM context and by "persisting" the process definition. So... what is the whole Scheduler thing about!?!?!? What am I doing wrong? anonymous wrote : | anonymous wrote : | | However, after some trials and debugging sessions I found that the solution to this problem is another one: you need to create a JbpmContext by yourself: | | | | This is also very basic jBPM stuff and in almost all examples, getting started. So I it sounds strange to me that you only found this out through debugging. | Please, don't talk about the jBPM 3 silly configuration mechanism otherwise we could discuss for an entire week!!! I always throw up my hands in desp
[jboss-user] [jBPM Users] - Re: How to use timers?
Nice explanation Ronald ! Mauromol, make sure you have: | | in your jbpm.cfg.xml View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4267141#4267141 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4267141 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [jBPM Users] - Re: How to use timers?
First of all, let me point you to http://catb.org/~esr/faqs/smart-questions.html#volume Personally, when I started reading your post and encounter very basic questions with statements that are plain wrong (see further on, and my previous post) in combination with LOTS of data (will not call it information), I really hesitate to respond, but since I'm in a really good mood anonymous wrote : The first problem I encounter is a "service 'scheduler' unavailable" error. Searching on the net I found some hints like "start the scheduler" or "change the configuration in src/main/config/jbpm.cfg.xml. Isn't the internet great anonymous wrote : But nobody explains WHAT is the scheduler, Are you serious? You did not ever get the impression that it is used to execute timers? Strange since you have a problem with timers and a message that the scheduler is unavailable and you started searching in this direction. Oh, and it is in the first chapter of the user docs: http://docs.jboss.org/jbpm/v3/userguide/introduction.html#d0e130 anonymous wrote : how to start it, etc.. Besides in the docs: http://docs.jboss.org/jbpm/v3/userguide/deployment.html#webapplication Very little searching yielded http://www.jboss.org/index.html?module=bb&op=viewtopic&t=80078&postdays=0&postorder=asc&start=10 and many more links anonymous wrote : However, after some trials and debugging sessions I found that the solution to this problem is another one: you need to create a JbpmContext by yourself: This is also very basic jBPM stuff and in almost all examples, getting started. So I it sounds strange to me that you only found this out through debugging. anonymous wrote : However, as I'm working with no database at all, I wouldn't expect that. You yourself might not be, but does it come as a surprise that jBPM might need one? jBPM is a statemachine, mainly for workflow, so long running processes. Most people would like that state to be persistent to survive a crash or restart. Most systems use a database for this (as does jBPM). I hope this already helps you as I did not look into your two specific cases. View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4267134#4267134 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4267134 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [jBPM Users] - Re: How to use timers?
more detailed response later this evening but for now: anonymous wrote : First of all: is there any documentation on it? The jBPM 3 user guide explains something like NOTHING on this subject... | http://docs.jboss.com/jbpm/v3.2/userguide/html_single/#tasktimers http://docs.jboss.com/jbpm/v3.2/userguide/html_single/#scheduler http://docs.jboss.com/jbpm/v3.2/userguide/html_single/#timer.element http://fisheye.jboss.org/changelog/JbpmSvn/jbpm3/trunk/modules/core/src/test/java/org/jbpm/scheduler/exe?todate=1248416261336 etc (including several posts in the forum)... so saying there is no documentation is plain wrong ;-). View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4267121#4267121 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4267121 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user