Author |
Message
|
mickey1691 |
Posted: Wed Jul 10, 2013 1:40 am Post subject: Message Flow - Execute on startup only |
|
|
Novice
Joined: 04 Jun 2013 Posts: 19
|
Is there any way to make a message flow run once and only once and only when the app is deployed to the message broker? Thanks |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Jul 10, 2013 3:29 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Start it with an MQInput node.
Only ever send messages to the MQInput node when you deploy the flow. |
|
Back to top |
|
 |
bruce2359 |
Posted: Wed Jul 10, 2013 4:01 am Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
Moved to Message Broker forum. _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
 |
Tibor |
Posted: Wed Jul 10, 2013 4:22 am Post subject: |
|
|
 Grand Master
Joined: 20 May 2001 Posts: 1033 Location: Hungary
|
If you can explain, why it is important, it is easier to find a solution... |
|
Back to top |
|
 |
mickey1691 |
Posted: Wed Jul 10, 2013 5:45 am Post subject: |
|
|
Novice
Joined: 04 Jun 2013 Posts: 19
|
A feature of the app we're making includes putting objects from a database into the broker's cache at the start of the application/broker. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Wed Jul 10, 2013 5:53 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
mickey1691 wrote: |
A feature of the app we're making includes putting objects from a database into the broker's cache at the start of the application/broker. |
WMB is a high-speed messaging engine. As such, flows are designed like jet engines: if they stop your in trouble.
Take a different approach. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
Tibor |
Posted: Wed Jul 10, 2013 5:57 am Post subject: |
|
|
 Grand Master
Joined: 20 May 2001 Posts: 1033 Location: Hungary
|
lancelotlinc wrote: |
Take a different approach. |
Agreed. I think a more proper way to develope a subflow for initializing your cache. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Jul 10, 2013 6:24 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Tibor wrote: |
lancelotlinc wrote: |
Take a different approach. |
Agreed. I think a more proper way to develope a subflow for initializing your cache. |
The problem with this is that it delays the very first message processed after a deploy.
This might be unacceptable.
However, doing the load in a separate flow means that the main flow still has to block if the cache is not loaded. Which could still delay the first message through. |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Jul 10, 2013 6:30 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
you could put the same subflow into all the flows. This would load the cache but include a test to not do anything if the cache was initialised.
This is a pretty generic problem and one that must have been solved already in sites that use it. It would be interesting to hear how they have done this.
The various alternatives would make a nice Redbook/RedPaper
{hint-hint} _________________ 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 |
|
 |
lancelotlinc |
Posted: Wed Jul 10, 2013 6:42 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
mqjeff wrote: |
Tibor wrote: |
lancelotlinc wrote: |
Take a different approach. |
Agreed. I think a more proper way to develope a subflow for initializing your cache. |
The problem with this is that it delays the very first message processed after a deploy.
This might be unacceptable.
However, doing the load in a separate flow means that the main flow still has to block if the cache is not loaded. Which could still delay the first message through. |
Cache loading generally happens in the constructor of your Singleton object if you have one. This method does not hold up the first message, and the cache gets loaded at startup. Be sure to have ample logging. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Jul 10, 2013 6:50 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
lancelotlinc wrote: |
Cache loading generally happens in the constructor of your Singleton object if you have one. This method does not hold up the first message, and the cache gets loaded at startup. Be sure to have ample logging. |
A Singleton is a design pattern.
It is not a specific Java class.
Yes, this could be done in this specific case, a Java object could be created that uses the Singleton pattern, and that object could be instantiated from a JavaCompute node init method.
Regardless, any user of a cache has to be aware of those conditions in which the cache is properly preloaded and those cases where the cache is improperly empty, and make decisions about how to handle this, including making a request for the cache to be loaded and blocking until it is reloaded.
Another possible implementation is a TimeoutNotification node that fires off every day or week or hour, and checks if the cache is loaded or not, and loads it if it isn't. |
|
Back to top |
|
 |
vikas.bhu |
Posted: Fri Jul 12, 2013 3:37 am Post subject: |
|
|
Disciple
Joined: 17 May 2009 Posts: 159
|
@mickey1691:you can take help of timer nodes and achive it. |
|
Back to top |
|
 |
|