Author |
Message
|
smdavies99 |
Posted: Sun Jun 26, 2016 8:26 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
ibmpro wrote: |
I like the idea of a master timer flow. .. can you explain this thanks
where we can set them .. and how.
appreciate |
The master Timer flow is quite simple to setup.
The ESQL to make sure the timer runs every minute on the miniute is as follows
Code: |
CREATE COMPUTE MODULE SYSTEM_Master_Timer_Setup_60SecondTimer
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE cTimerTime CHARACTER;
DECLARE iSecs INTEGER 0;
-- Create The message Tree
SET OutputRoot.Properties = InputRoot.Properties;
CREATE LASTCHILD of OutputRoot DOMAIN 'MQMD' NAME 'MQMD';
SET OutputRoot.MQMD.Version = 2;
CREATE LASTCHILD of OutputRoot DOMAIN 'XMLNSC' NAME 'XMLNSC';
CREATE FIELD OutputRoot.XMLNSC.TimeoutRequest;
DECLARE outRef REFERENCE to OutputRoot.XMLNSC.TimeoutRequest;
CREATE LASTCHILD OF outRef NAME 'Action' VALUE 'SET';
CREATE LASTCHILD OF outRef NAME 'Identifier' VALUE 'SYSKeepAlive';
--
-- Schedule a timer to fire every 60 seconds as close as possible to the Zero seconds mark of the minute
--
-- Get the current time
--
DECLARE tNow TIME CURRENT_TIMESTAMP;
--
-- Get the seconds past the minute
--
SET iSecs = CAST(CAST(tNow as CHAR format 'ss') as INTEGER);
--
-- if iSecs = say 34 then we schedule a time to start at
-- the next minute less 26 seconds.
--
set iSecs = 60 - iSecs; -- calc the seconds ramaining in the minute
DECLARE tStartTime TIME;
set tStartTime = tNow + cast (iSecs as INTERVAL SECOND);
set cTimerTime = SUBSTRING(CAST( tStartTime as CHAR) from 7 for 8);
--
-- now format the rest of the timer control message
--
CREATE LASTCHILD OF outRef NAME 'StartDate' VALUE 'TODAY';
CREATE LASTCHILD OF outRef NAME 'StartTime' VALUE cTimerTime;
CREATE LASTCHILD OF outRef NAME 'Interval' VALUE '60'; -- Repeat after 30 seconds.
CREATE LASTCHILD OF outRef NAME 'Count' VALUE '-1'; -- repeat forever
CREATE LASTCHILD OF outRef NAME 'IgnoreMissed' VALUE 'TRUE';
CREATE LASTCHILD OF outRef NAME 'AllowOverwrite' VALUE 'TRUE';
return TRUE;
END;
END MODULE; |
A timeoutnotification node is wired into a compute node that has the above ESQL. This is wired into a timeout control node. The FIRST Timeoutnotification node is set to fire every 24 hours. But the key thing is that when a flow or an execution group is started it fires. The ESQL takes advantage of that to schedule another timer. The Configured properties of the two nodes make it work.
Then the second node is fed into a Compute node that uses a DB table to decide what to do. Each event time causes a message to be sent to a queue (defined in the table). The basic message is also in the table. These just act as triggers for those flows.
Therefore we can keep the operations to be performed in a DB table. We also have an indicator in the table that allows us to record the last time an event was sent off in the table. Mostly, this is disabled.
So take this concept and go with it and make it work for you if appropriate. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
ibmpro |
Posted: Sun Jun 26, 2016 9:02 am Post subject: |
|
|
Novice
Joined: 20 Jun 2016 Posts: 11 Location: USA
|
Thank you very much smdavies99 i will check this ,
i have continues inquiry for this topic .. the question is
every midnight the DB will be fill-in by requester fresh records almost 15000 records , then using esql commands will invoke these records and send them to external Database .
the requirement is one of these tow solutions 1-clear the DB from these records so that the table will be ready for the next day records .
or 2- To differentiate each day record by providing unique ID so we can manage each day records individually .
will you please help on esql commands can help on theses two options as a sample .
Appreciate .
Thanks |
|
Back to top |
|
 |
smdavies99 |
Posted: Sun Jun 26, 2016 10:57 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Ok, here in general terms is how I'd do it.
1) use a select that produces the first 'n' records in the DB.
for SQLServer it would be something like
'select top 100 * from <DB-Table> order by 1'
2) write these to the new DB
3) Delete each record from the old DB
and here is the important bit
end the transaction by finishing the flow but only after sending a message to the input Q of the flow so that it would start again.
Repeat until all done.
A word of advice.
We don't do your job for you here. I've given you some directions on how to solve the problem.
Give it a go and let us know what problems you encounter. Then we can help you solve specific problems.
That way, you will learn more than if we gave you the solution in its entirety. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
ibmpro |
Posted: Sun Jun 26, 2016 11:13 am Post subject: |
|
|
Novice
Joined: 20 Jun 2016 Posts: 11 Location: USA
|
|
Back to top |
|
 |
joebuckeye |
Posted: Tue Jun 28, 2016 4:09 am Post subject: |
|
|
 Partisan
Joined: 24 Aug 2007 Posts: 365 Location: Columbus, OH
|
Thanks for the timer code smdavies.
We are ramping up a project to update our v8 infrastructure to IIB.
We have a lot of cron entries now to fire off jobs at specific times and management wants us to get away from cron. Why? Because even though cron is super easy it seems that a lot of people are scared by doing anything on a command line.
The big issue for us has always been these jobs need to run at specific times and the plain old timer nodes don't give you that functionality.
We'll probably use this code as a POC to see if we can get our absolute time scheduler working. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Jun 28, 2016 4:27 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
|
Back to top |
|
 |
|