03-01-2015 06:38 PM
Hi,
I'm trying to find a solution for a process as follows:
1) A process(1) is initiated at CPO via Northbound Web Services.
2) The process(1) has 2 input parameters: Starting DateTime and Duration (hours)
3) The process(1) needs to start schedule/start a second process(2) based on the Starting DateTime.
4) Then process(1) needs to calculate the EndTime (Starting DateTime + Duration) and schedule the third process(3) based on the calculation.
Can someone help me with this?
Thanks and regards,
Lui
03-02-2015 05:22 AM
I would use a queue mechanism for this personally. (you cannot create calendars/schedules dynamically) so i would do this...
1) Have process(1) enter the process name and start DateTime into a queue. (this would normally be a global table). I have a queue class out there if you want to use it, nothing special but I use it a lot. It is at https://supportforums.cisco.com/document/12283171/basic-queue-target-typeclass-cpo
2) Have process(2) (or another process even) run every couple minutes and check it's queue for the matching process name and DateTime that is equal or has passed. Depending on how exact you want to be you could even bump this out to 5 minute checks.
*ANOTHER WAY* You might also try the variable updated trigger(if using global variable table for queue) or you can use the target updated(if you used my queue class). Trigger based off that being updated and then start process(2). You can sleep process(2) then until it passes the DateTime to start(then unsleep it)
3) Have process(3) use the "Process State Change" trigger and have it just trigger when process(2) succeeds or fails(basically when process(2) is done). That way you do not need to worry about the duration of process(2).
I think you have a couple of options, the biggest variable to me is how/when you start process(2). Process(3) is very straight forward in using the process state change trigger.
--shaun
03-02-2015 02:08 PM
Thanks Shaun,
You gave me another idea. Where I start process(2) straight away getting the start date/time as input and sleep until the date/time is reached. Then sleep for "n" seconds and then start process(3).
I'm quite new to CPO. Would you help me showing how to test if date/time is reached? I'm assuming I will pass it as a String Input Variable from the SOAP request.
Thanks
Lui
03-03-2015 04:59 AM
Lui,
Yes you can pass it as a string. This is currently the only option as DateTime is not a valid input variable type (yet). You have to pass in the DateTime as a string, say "2015-03-03 12:00:00" or something like that. (however you DateTime shows)
You then need to pass that into the Parse Date activity which will convert the string to an actual DateTime variable in CPO. You will have to setup the "format string" to be the proper format you want your date time to show in and then the input string would be your input variable string.
That would give you your base date/time to reach. You can then compare that date/time to the end date/time of the last activity that ran in the process(probably the sleep). If the datetime of your input is not pass it, then sleep for N seconds and compare again. (this would all be in a while loop)
Another way would be to get the base date/time from input. Then get the difference in time (seconds) using the Calculate Date Time Difference activity from the last activity that ran to the base date/time. Using the difference in seconds as the output from the Calculate Date activity, pass those amount of seconds into a single sleep activity and just sleep for those "N" seconds.
That is how I would accomplish it. The 2nd way is more efficient but a little more complex to think about.
--Shaun
03-03-2015 01:45 PM
Thanks Shaun,
I really appreciated your help. I will try it and let you know...
Cheers,
Lui
03-03-2015 09:12 PM
Hi Shaun,
I implemented the second solution (calculate date/time diff) and it's working well. My question to you is whether having processes sleepping for a considerable amount of time (perhaps a day or two) would cause any performance/stability problems with CPO.
Thanks
Lui
03-04-2015 04:24 AM
No, not that I would think. Unless you have thousands and thousands of processes sleeping and it just starts to fill up the *.Instance tables in the DB. If that was the case, then I would suggest using the Queue idea I had above and have a queue checker run once every 5 mins or so and check for processes in queue that need to run. But if you are talking <100 at once, then no, I think the sleep will be ok.
--Shaun
03-04-2015 03:26 PM
Thanks Shaun,
We expect no more than 3 or 4 of these processes being active at the same time.
Your help was very appreciated.
Lui
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide