Author |
Message
|
Sunrise |
Posted: Thu Jun 27, 2013 9:21 pm Post subject: How to delay the Message Flow using esql code in MB6.1 |
|
|
Newbie
Joined: 27 Jun 2013 Posts: 3
|
How to stop or delay the message flow for certain time (Eg: 5 minutes) using esql compute code, not using JavaCompute node.(I am Using MB 6.1). Appriciate your great help.
Thanks,
Ram |
|
Back to top |
|
 |
smdavies99 |
Posted: Thu Jun 27, 2013 9:33 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Welcome to the Forum
1) Are you aware that 6.1 goes out of service very shortly?
2) This question has been asked before
3) There is an old by actually relevant IBM Red-Book on the timer nodes that may help.
However, a word of caution.
Generally this is not a good idea.
If you have a genuine reason for wanting to delay the processing of something for that long then please share it with us. Then we can guide you towards the most appropriate solution. _________________ 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 |
|
 |
Tibor |
Posted: Fri Jun 28, 2013 1:17 am Post subject: |
|
|
 Grand Master
Joined: 20 May 2001 Posts: 1033 Location: Hungary
|
You can try something like this:
Code: |
DECLARE tStart TIMESTAMP CURRENT_TIMESTAMP;
X : WHILE (CURRENT_TIMESTAMP - tStart) < INTERVAL '5' SECONDS DO
END WHILE X; |
...but it would be very CPU consuming and highly disapproved  |
|
Back to top |
|
 |
zpat |
Posted: Fri Jun 28, 2013 1:41 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Do not tight loop - you will get (or should be) fired for doing that.
Use a MQGET node against an empty queue with a wait interval of the delay time required.
You can call this from ESQL using a propagate, if preferred.
Lateral thinking....  |
|
Back to top |
|
 |
Sunrise |
Posted: Fri Jun 28, 2013 3:11 am Post subject: |
|
|
Newbie
Joined: 27 Jun 2013 Posts: 3
|
Thanks to replay for all.
According to my requirement I can't use the MQGet Node here.
Using esql code i need to stop the thread for 2 minutes at certain point and i need to execute the rest of the code after 2 minutes in the flow. |
|
Back to top |
|
 |
smdavies99 |
Posted: Fri Jun 28, 2013 3:16 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Sunrise wrote: |
Thanks to replay for all.
According to my requirement I can't use the MQGet Node here.
. |
Perhaps the requirement is wrong?
Does the person creating this requirement actually know even the basics of Message Broker?
Why do they want to delay processing anyway?
I posted a thread some time ago called 'And the Requirement is'. It might be worth reading. _________________ 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 |
|
 |
rekarm01 |
Posted: Fri Jun 28, 2013 3:20 am Post subject: Re: How to delay the Message Flow using esql code in MB6.1 |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
Tibor wrote: |
You can try something like this:
Code: |
DECLARE tStart TIMESTAMP CURRENT_TIMESTAMP;
X : WHILE (CURRENT_TIMESTAMP - tStart) < INTERVAL '5' SECONDS DO
END WHILE X; |
...but it would be very CPU consuming and highly disapproved  |
All calls to CURRENT_TIMESTAMP within the processing of one node are guaranteed to return the same value, so the loop may run a bit longer than expected.
Sunrise wrote: |
Using esql code i need to stop the thread for 2 minutes at certain point and i need to execute the rest of the code in the flow. |
For WMB 6.1, this is not possible with ESQL alone. Either upgrade to WMB 7.0 or later, or provide an external function, or use other nodes. |
|
Back to top |
|
 |
zpat |
Posted: Fri Jun 28, 2013 3:21 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
You don't understand.
In the ESQL code - code a propagate statement to a terminal name that is connected to a MQGET node.
Control will pass to that terminal - enter the MQGET node and wait for the interval time (2 mins in your case) set on that node (use an empty queue).
Then control will resume in the compute node - EXACTLY where it was before.
Read about the Propagate statement. It works synchronously.
This will work, trust me.
Just create a new output terminal (e.g called outwait) on the compute node and connect that terminal to a MQGET node.
Then call that terminal with propagate from the ESQL inside the compute node. It's like a subroutine call and effectively embeds the MQGET inside the compute node. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Fri Jun 28, 2013 3:43 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Sunrise wrote: |
Thanks to replay for all.
According to my requirement I can't use the MQGet Node here.
Using esql code i need to stop the thread for 2 minutes at certain point and i need to execute the rest of the code after 2 minutes in the flow. |
Sounds like your manager is coming up with technical requirements. That is even a more disastrous idea than the requirement.
What's the point of waiting? What are you waiting for?
Also who is prohibiting you from using particular nodes? If a node provides needed functionality, why are you not allowed to use it? _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Last edited by lancelotlinc on Fri Jun 28, 2013 4:09 am; edited 2 times in total |
|
Back to top |
|
 |
zpat |
Posted: Fri Jun 28, 2013 3:46 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Code: |
--- ESQL before the wait is here
PROPAGATE TO TERMINAL 'outwait' FINALIZE NONE DELETE NONE;
--- ESQL after the wait is here
|
|
|
Back to top |
|
 |
NealM |
Posted: Fri Jun 28, 2013 6:13 am Post subject: |
|
|
 Master
Joined: 22 Feb 2011 Posts: 230 Location: NC or Utah (depends)
|
As a couple folks have already suggested, the MQGet timeeout is an ideal way of doing a low cost (CPU-wise) flow delay. If the issue is not wanting to add a queue for this purpose (short sighted as the queue's name can easily distinguish its purpose), just use an already existing queue, preferably one with low activity, but make sure your "match" will be impossible to ever really occur.
Also, remember, if that flow is paused and it is a single instance, then any other messages expected to flow through will be delayed until the flow completes. Perhaps that is the intention.
Regarding folks questioning any requirements for a built in flow delay, I'm sure if a poll were taken they would find there are more than a few practitioners who have seen legitimate requirements for a variety of reasons. |
|
Back to top |
|
 |
zpat |
Posted: Fri Jun 28, 2013 6:21 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
There is an ESQL sleep function in WMB 7.
This was just a way to do something similar in WMB 6.1. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Fri Jun 28, 2013 6:45 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
NealM wrote: |
Regarding folks questioning any requirements for a built in flow delay, I'm sure if a poll were taken they would find there are more than a few practitioners who have seen legitimate requirements for a variety of reasons. |
The question is: what is being accomplished by delaying the flow with a Sleep (or eqv) and why is some other approach not considered ?
Also: what is the rationale for prohibiting the use of JCNs and MQGet nodes ? _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
zpat |
Posted: Fri Jun 28, 2013 7:28 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Message flows shouldn't wait.
Ideally a flow would terminate if it needs a response and the response would start another flow.
That way the message flow can handle the maximum amount of work. However when using protocols inferior to MQ (that is - all of them) it's not always possible to do this.
In which case look at parallelism, but generally any wait interval (or just waiting for a response synchronously) will introduce a limiting factor to throughput and/or cause latency.
Always keep waits short and bear in mind someone may want to stop the message flow, EG or the broker, you may hold that action up. |
|
Back to top |
|
 |
Tibor |
Posted: Sat Jun 29, 2013 4:30 am Post subject: |
|
|
 Grand Master
Joined: 20 May 2001 Posts: 1033 Location: Hungary
|
zpat wrote: |
Message flows shouldn't wait. |
If your message flow was added enough multiple instances, your flow can wait. But not really effective... |
|
Back to top |
|
 |
|