|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
Global/ Shared Variables in Msg Flow |
« View previous topic :: View next topic » |
Author |
Message
|
mikepham |
Posted: Thu Feb 17, 2011 3:20 am Post subject: |
|
|
 Novice
Joined: 17 Mar 2010 Posts: 20
|
mqjeff wrote: |
If you're creating common code that is going to be used to do some particular task and reused in many message flows that you aren't writing, then yes using a shared variable is a 'safer' method than using LocalEnvironment or Environment.
You just have to pay attention to module vs schema scope issues, like you've seen, and you probably want to put your ESQL /flows into it's own schema (like a java pacakge) |
You're right mqjeff, that's my situation now. To avoid confusing for msgflows under same schema, I create shared variables with unique name for each of them.
Sorry if my question below is ridiculous, it's the only problem that i'm concerned about using shared variable in my case right now
Can two msg (one after one) came into my msgflow at the same time and the 1st msg run thru a node and save a value to shared variable, the 2nd msg overwrite it. ?
What I hope is my msgflow processes 1st msg and after it comes to output successfully then the 2nd one come in to be processed |
|
Back to top |
|
 |
mgk |
Posted: Thu Feb 17, 2011 3:41 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Quote: |
Can two msg (one after one) came into my msgflow at the same time and the 1st msg run thru a node and save a value to shared variable, the 2nd msg overwrite it. |
Yes, if you add any "additional instances" to a flow (which map to extra threads). Shared variables have a scope longer than a single message. If you want "single message" scope then use the Environment tree. This tree is created when a message arrives at an input node, and is available to any node in the tree. As long as you choose a location in the tree that will not "clash" by name with any other node using the Environment then you can be sure your data will be in the tree (unless a given node deleted your part of the Environment) in which case you need to change that node or your location in the tree... _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
mikepham |
Posted: Thu Feb 17, 2011 6:29 am Post subject: |
|
|
 Novice
Joined: 17 Mar 2010 Posts: 20
|
mgk wrote: |
Quote: |
Can two msg (one after one) came into my msgflow at the same time and the 1st msg run thru a node and save a value to shared variable, the 2nd msg overwrite it. |
Yes, if you add any "additional instances" to a flow (which map to extra threads). Shared variables have a scope longer than a single message. If you want "single message" scope then use the Environment tree. This tree is created when a message arrives at an input node, and is available to any node in the tree. As long as you choose a location in the tree that will not "clash" by name with any other node using the Environment then you can be sure your data will be in the tree (unless a given node deleted your part of the Environment) in which case you need to change that node or your location in the tree... |
I know the side-effect when using more than one instance of msgflow + shared variables.
Since in my situation I'm using *only* one instance for a msgflow, am I okay to use shared variables without issue above ? And only one msg can be processed in my msgflow at a time ? |
|
Back to top |
|
 |
mgk |
Posted: Thu Feb 17, 2011 7:32 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Quote: |
Since in my situation I'm using *only* one instance for a msgflow, am I okay to use shared variables without issue above ? And only one msg can be processed in my msgflow at a time |
If you have 0 additional instances and only have one input node in the flow (as each input node automatically gets a thread) and can be sure that no admin in the future will not add an additional instance to improve the throughput if demand increases, and do not use any of the nodes that cause note than one thread to be used (collection / agregation / async soap etc) then you may be ok... Personally in this case, where you want no interaction between messages, I would use the Environment tree to store the data then you can scale out without any worries...
Kind regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
mikepham |
Posted: Thu Feb 17, 2011 7:50 am Post subject: |
|
|
 Novice
Joined: 17 Mar 2010 Posts: 20
|
mgk wrote: |
If you have 0 additional instances and only have one input node in the flow (as each input node automatically gets a thread) and can be sure that no admin in the future will not add an additional instance to improve the throughput if demand increases, and do not use any of the nodes that cause note than one thread to be used (collection / agregation / async soap etc) then you may be ok... Personally in this case, where you want no interaction between messages, I would use the Environment tree to store the data then you can scale out without any worries...
Kind regards, |
Thanks for your explanation
Yes I'm have 0 additional instances and only have one input node in the flow
I'm sure in near future no admin will add an additional instance to improve the throughput. (they may put the same msgflow in other EG to improve the throughput)
I know there is Environment can do but...
Quote: |
creating common code that is going to be used to do some particular task and reused in many message flows that you aren't writing, then yes using a shared variable is a 'safer' method than using LocalEnvironment or Environment. |
|
|
Back to top |
|
 |
|
|
|
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
|
|
|
|