ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » URGENT!!!!! HOW TO SLEEP A FLOW EXECUTION

Post new topic  Reply to topic
 URGENT!!!!! HOW TO SLEEP A FLOW EXECUTION « View previous topic :: View next topic » 
Author Message
danielaphex
PostPosted: Tue May 20, 2003 12:26 am    Post subject: URGENT!!!!! HOW TO SLEEP A FLOW EXECUTION Reply with quote

Apprentice

Joined: 07 Apr 2003
Posts: 28

Hi to everyone,

I am getting into trouble when trying to implement a WMQSI Message Flow which must sleep its execution for a concrete period of time.
My first steps led me to develop a code like this:

Quote:

-- Variables declaration
DECLARE FECHAACTUAL TIMESTAMP;
DECLARE INTERVALO CHAR;
DECLARE VARIACION INTERVAL;
DECLARE FECHAFINAL TIMESTAMP;

-- Extract the current time
SET FECHAACTUAL = CURRENT_TIMESTAMP;

-- An interval of 10 seconds
SET INTERVALO = '10';

-- Casting to IRTERVAL
SET VARIACION = CAST (INTERVALO AS INTERVAL SECOND);

-- Get the final timestamp
SET FECHAFINAL = FECHAACTUAL + VARIACION;

WHILE (FECHAACTUAL <= FECHAFINAL) DO

-- It is calculated a new TIMESTAMP
SET FECHAACTUAL = CURRENT_TIMESTAMP;

-- It is hoped that the flow execution slept here for 10 seconds

END WHILE;


But, as WMQSI ESQL Reference Tutorial tells us, the function CURRENT_TIMESTAMP does not change its value from inside a node belonging to a determinated flow so It is not possible to 'stop' a flow execution by following this estrategy.

Does anybody happen any way to get this goal?

I really would appreciate any kind of help.

Thanks a lot,
Back to top
View user's profile Send private message
zpat
PostPosted: Tue May 20, 2003 12:53 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

If you code a hard loop like that - you will consume all the CPU in your broker, so even if the timestamp updated - this is not a good idea.

To sleep properly requires that some sort of system wait is used whereby the operating system suspends the thread and later re-dispatches it.

The most obvious way to achieve this would be to code a plug-in node in C or Java that can issue the appropriate system function call.

You can probably adapt one of the support pacs plug-in samples by inserting a sleep call into the code (and removing the other stuff).
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue May 20, 2003 5:29 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

It is not a recommended practice to have a message flow sleep in any sense.

The main reason it is not recommended is that the message flow is suspended, and so it is not responsive to operational commands. This means it could prevent the broker from shutting down or prevent the execution group from shutting down. What's even worse is that it will prevent the execution group from responding to commands as well. So you can't do ANY full deploys to that broker, as the execution group won't respond.

What are you trying to do, that you want your message flow to pause? And what version are you running, anyway?
Back to top
View user's profile Send private message
zpat
PostPosted: Tue May 20, 2003 6:03 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

WMQI/MQSI flows should generally be stateless.

If you want to wait for a reply from another system, then send it a message and end the flow. Have the reply message initiate another flow.

Carry any state data with the message, or store it in the broker database.

The only real reason to wait is to maintain a single unit of work while calling an external system. In such a case you are likely to have to use a plug in node in any event.
Back to top
View user's profile Send private message
danielaphex
PostPosted: Wed May 21, 2003 7:18 am    Post subject: Reply with quote

Apprentice

Joined: 07 Apr 2003
Posts: 28

I really appreciate everyone,s help but, althought I know that this kind of design is not the best way to implement a funcionality by using WMQSI, I consider I need it.
Lets go to take into account my flow particular considerations.

My goal is to wait until a new record appear in a DB2 database while the time spent does not exceed a predefined time-out. So I think I should code a hard loop that makes a query to the mentioned DB2 table for a determinated period.

Does anybody know any way to cover this requirement??
Back to top
View user's profile Send private message
tbt102
PostPosted: Wed May 21, 2003 8:48 am    Post subject: Reply with quote

Apprentice

Joined: 21 Apr 2003
Posts: 28

Hi danielaphex,

Have you tried attacking this from the DB point of view?

You should be able to set up a trigger and/or stored procedure that will put new records that appear in a DB2 database table onto a queue.

This will add some DB overhead. How much will depend on the number and/or frequency of new records. However the upside is your flow implementation should be cleaner.

Hope this helps.
Back to top
View user's profile Send private message
zpat
PostPosted: Thu May 22, 2003 12:23 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

You must use a thread SLEEP function, coding a hard loop is something that most companies would FIRE any programmer for doing on a system that runs more than a single application. You will waste system resources and prevent any other thread from using your processor time.

Get a friendly Java or C programmer to adapt one of the plug-ins to have a thread sleep call in. Code a MQSI flow with a database query and then pass control through the sleep node and loop it around.

Not ideal, but at least you will only lock out the execution group thread and not totally stress the system at the same time. No-one uses "hard loops" unless you were designing something like a imbedded application for use in a kids toy.

The proper design would be to have some other application waiting/looking for the DB2 update and then sending a message into the broker to initiate a flow. You should not really wait in the broker.

If your broker is to be used by any other applications and you do perform any kind of intense loop or wait - please explain to these other guys that you are about to have a major impact on their apps!
Back to top
View user's profile Send private message
MikeTamari
PostPosted: Thu May 22, 2003 4:15 am    Post subject: Use the TIMER plug in... Reply with quote

Apprentice

Joined: 04 Feb 2002
Posts: 26

I have just started experimenting the TIMER plug in node, IA0K, I also have some flows that need s "wait and check" functionality.
I didn’t fully check my solution to this problem but I think it should work.

Once in the flow, after querying your DB2 and having the need t "wait and retry",
1.send an inhibit message to your queue(that initiated the actual flow)(using pcf commands)
2.initiate a timer flow that periodically sends a message to another queue(very simple, timer can be set to any interval)
3.create a 2nd flow listening to the 2nd queue that queries your DB2
4.Once this 2nd flow finds the appropriate record in the DB2 it will send a "cancel timer" message to the message flow and enable the first queue, thus letting the original flow run, knowing that the required data exists in the DB2.

This may look a little "heavy" but :

The timer plug in is very simple to use.
You will hardly affect cpu usage.
You will achieve your goal.

So what do you think ?
Back to top
View user's profile Send private message Send e-mail
kirani
PostPosted: Thu May 22, 2003 3:40 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Writing a plug-in input node could also help in implementing this design.
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » URGENT!!!!! HOW TO SLEEP A FLOW EXECUTION
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.