cancel
Showing results for 
Search instead for 
Did you mean: 

How can I run a scheduled process on simple java application?

wuaner
Champ in-the-making
Champ in-the-making
Hi,

I have a scenario that need to start a processing instance for every user that registered 5 days ago. Because is more like a scheduled job(but the processing for each user is workflow), so i want to implement it with simple java app + cron(Run every day for users that registered 5 days ago).

But the question is,  how can I trigger the already exist process instances to be continue on cron-triggered simple java app? is Activiti must be run on a Web container, for example, tomcat?

Sorry for my poor English.

Regards.
6 REPLIES 6

trademak
Star Contributor
Star Contributor
That depends on the state of the running process instances. Is the current state for example a receive or user task? You can use the Activiti Java API to lookup a process instance and trigger it based on the current state task type. So no, you don't need a web container.

Best regards,

wuaner
Champ in-the-making
Champ in-the-making
Hi Tijs, thank you so much for your prompt response!

I am thinking of use timing catching event and service task for subsequent execution. Because there is no human activity involved in the processing(user task), and no message interaction(receive task). I am working on a social network site, here is the brief scenario of my business logic:

For every user NEW_USER that registered 5 days ago:
Use a fake user FAKE_USER_A, sending friend invitation to NEW_USER;
—-3 days later, check the invitation was accepted or not;
——–If yes, use FAKE_USER_A send a message to NEW_USER;
————2 days later, check the message was responded or not;
—————-if yes, use FAKE_USER_A send response-message to NEW_USER;
—————-if not, end;
——–if not, use fake user FAKE_USER_B sending a message to NEW_USER;
————2 days later, check the message was responded or not;
—————-if yes, use FAKE_USER_B send response-message to NEW_USER;
—————-if not, end;

I can not figure out how can I run these scheduled process instances on a cron-triggered simple java application? and this is also a batch processing.

Any response would be greatly appreciated.


Regards.

jbarrez
Star Contributor
Star Contributor
You can have one 'master' process with a start event timer that does these checks regulary.
When conditions are met, it starts new process instances. If not, it just completes.

wuaner
Champ in-the-making
Champ in-the-making
Hi jbarrez,
Thank you so much for your response, and sorry for my late reply.
I have one more concern. Because i need start tens of thousands of process instances simultaneously, is workflow engine like Activiti suitable for this? Is there any chances we got pressures on JVM, memory or disk?

frederikherema1
Star Contributor
Star Contributor
Do you mean you want to start 10000+ processes from within the other process?
- If so, this *can* be problematic because the processes will be started in the same transaction as the API-call (or timer-fire) that kicks off that logic. Depends on transaction-size of your DB and can use alot of memory.
- If not (so you're just starting processes using the API in some kind of loop/pool) this is no issue. Engine execution itself has very little overhead in CPU-time. Most time is spent in DB-logic (also optimized to prevent unneeded insert/update/deletes) and user-code offcourse (e.g.. you calling a service). If you disable (or lower the level) of the history, you can limit the DB-writes to a bare minimum.

Hi frederikheremans,

It's not. I just want to staring 10k+(approximately up to 100k) process instances in loops, as you mentioned in #2. So there is no issue here, thank you so much for clearing things up.

Regards.