|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
SHARED, EXTERNAL of DECLARE Statement |
« View previous topic :: View next topic » |
Author |
Message
|
kevin_22 |
Posted: Mon Jul 17, 2006 4:14 am Post subject: SHARED, EXTERNAL of DECLARE Statement |
|
|
 Centurion
Joined: 08 Mar 2005 Posts: 100
|
Hi,
I am trying to explore myself in Shared memory of MB6.0.
I am placing the statement " DECLARE ShareVal SHARED CHARACTER 'asdf' " before the CREATE MODULE and assining 'ShareVal' variable to the output tree in Funtion MAIN.
I am getting the below error while deploying the bar file.
Quote: |
The correlation name ''ShareVal'' is not valid. Those in scope are: 'Environment, InputLocalEnvironment, OutputLocalEnvironment, InputRoot, InputBody, InputProperties, OutputRoot, InputExceptionList, OutputExceptionList, InputDestinationList, OutputDestinationList'.
The first element of a field reference must be a valid correlation name, from those in scope. This message may sometimes be due to an incorrectly formed or spelled expression which is not intended to be a field reference being parsed as if it were a field reference because the parser does not recognize it.
|
I also want to know that 'can we extend this concept to Funtion and procedure ?' i.e, shared functions.
Please give me your ideas.
Thanks,
Kevin |
|
Back to top |
|
 |
elvis_gn |
Posted: Mon Jul 17, 2006 4:43 am Post subject: Re: SHARED, EXTERNAL of DECLARE Statement |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi kevin_22,
kevin_22 wrote: |
DECLARE ShareVal SHARED CHARACTER 'asdf' " |
I think it should be DECLARE ShareVal SHARED ROW if you are giving it outside the module(u can assign the value after declaring it i guess)...read up on the SHARED variable, there is some googly in it....if u declare it inside a module, it is local to that module and if you declare it outside modules, it is common to all the instances of the flow....i'm not very sure, but i think i understood this from the infocenter.
kevin_22 wrote: |
I also want to know that 'can we extend this concept to Funtion and procedure ?' i.e, shared functions. |
You can use functions and procedures across the projects....i don't understand what u meant by using SHARED for functions....i think only variables can be shared.
Regards. |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Jul 17, 2006 4:46 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
There's no reason you have to only share variables of ROW type outside modules, Elvis_gn.
So it's fine that that's a CHARACTER and not a ROW variable.
And, yes, you can only SHARE variables and not modules or functions or procedures. But that doesn't mean you can't use the same function in more than one module or project or ESQL file or etc.
Kevin_22, if you post what you are actually trying to do, rather than how you are trying to do it... we can give you a better answer. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
kevin_22 |
Posted: Mon Jul 17, 2006 5:08 am Post subject: |
|
|
 Centurion
Joined: 08 Mar 2005 Posts: 100
|
Hi,
Thanks for your response. My code looks quite simple.
I am having two flows in single project.
DateValidFlow flow contains:
Code: |
DECLARE ShareVal SHARED CHARACTER 'sharedvalue' ;
CREATE COMPUTE MODULE DateValidFlow_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();
SET OutputRoot.XML.Data.Base.ShareVal= ShareVal;
RETURN TRUE;
END; |
MessageFlow1 Flow contains:
Code: |
CREATE COMPUTE MODULE MessageFlow1_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
SET OutputRoot.XML.Data.MessageFlow1.ShareCopy = ShareVal;
RETURN TRUE;
END; |
The event viewer saying that:
Quote: |
WBI_BRK1.default ) ('', '6.51') : The correlation name ''ShareVal'' is not valid. Those in scope are: 'Environment, InputLocalEnvironment, OutputLocalEnvironment, InputRoot, InputBody, InputProperties, OutputRoot, InputExceptionList, OutputExceptionList, InputDestinationList, OutputDestinationList'.
The first element of a field reference must be a valid correlation name, from those in scope. This message may sometimes be due to an incorrectly formed or spelled expression which is not intended to be a field reference being parsed as if it were a field reference because the parser does not recognize it.
Correct the syntax of your ESQL expression in node '''', around line and |
Quote: |
( WBI_BRK1.default ) Syntax error in SQL statements in node 'MessageFlow1.Compute'.
The configuration failed due to errors in the SQL statement text. See the following messages for details of the error
The following error messages will give specific details of the location and nature of the error. Check and correct the syntax of the SQL statements and redeploy. |
Quote: |
WBI_BRK1.default ) Execution group ''default'' received an invalid configuration message. See the following messages for details of the error.
The message broker received an invalid configuration message and has not updated its configuration. This can arise as a result of errors in the specification of either message flows or message sets which the configuration manager was unable to detect. It can also result from a message flow requiring a type of node that is not supported by the broker installation, from the broker having become out of step with the configuration database or from other applications sending extraneous messages to the broker's configuration queues (SYSTEM.BROKER.ADMIN.QUEUE & SYSTEM.BROKER.EXECUTIONGROUP.QUEUE).
Check the relevant message flow and message set definitions, check that all necessary user-defined extensions are installed, perform a complete redeploy of the broker's configuration and ensure that no |
|
|
Back to top |
|
 |
elvis_gn |
Posted: Mon Jul 17, 2006 5:33 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi,
jefflowrey wrote: |
There's no reason you have to only share variables of ROW type outside modules, Elvis_gn.
So it's fine that that's a CHARACTER and not a ROW variable. |
I could have sworn that when i tried last time, only the row thing worked for me...
Now it is, so i stand corrected on that.
jefflowrey wrote: |
And, yes, you can only SHARE variables and not modules or functions or procedures. But that doesn't mean you can't use the same function in more than one module or project or ESQL file or etc. |
Well I got that one right
kevin_22 wrote: |
I am having two flows in single project. |
Are shared variables accessible across flows unless one flow is being called in the other....?? I notice that the shared variable is not being recognized by the MessageFlow1 but recognized by the DateValidFlow.
Regards. |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Jul 17, 2006 6:15 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
If you use a common ESQL file in two separate flows that has it's own schema and declares a SHARED variable - I'm almost 100% sure that there will be two variables and those variables will have different values.
That is, you can't use ESQL SHARED variables to access data between two different flows. So even if it's "the same" variable, it's a different variable with a different value. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Jul 17, 2006 10:34 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
To share variables within the execution group and possibly accross execution groups and brokers look at the cache support pack....
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kevin_22 |
Posted: Tue Jul 18, 2006 12:21 am Post subject: |
|
|
 Centurion
Joined: 08 Mar 2005 Posts: 100
|
Hi ,
Thanks for your replies. I created new project with two flows, this time the shared variable seems to working but i couldn't able to understand the functionality of that. please find the details below.
ESQL Code:
Flow1:
Code: |
DECLARE share1 SHARED CHARACTER 'flow1';
CREATE COMPUTE MODULE Flow1_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();
-- CALL CopyEntireMessage();
----------------------------
SET OutputRoot.Properties.MessageFormat = 'XML';
SET OutputRoot.XML.Data.Flow1.SharedVarible = share1;
set share1 = 'flow2';
RETURN TRUE;
END; |
flow2:
Code: |
CREATE COMPUTE MODULE flow2_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- CALL CopyMessageHeaders();
CALL CopyEntireMessage();
-------------------------------
SET OutputRoot.XML.Data.Flow2.SharedVarible = share1;
RETURN TRUE;
END; |
Output message:
First time with fresh deploy, when input message is placed input queue:
Quote: |
<Data>
<Flow1>
<SharedVarible>flow1</SharedVarible>
</Flow1>
<Flow2>
<SharedVarible>flow1</SharedVarible>
</Flow2>
</Data> |
when secound input message is placed in input queue:
Quote: |
<Data>
<Flow1>
<SharedVarible>flow2</SharedVarible>
</Flow1>
<Flow2>
<SharedVarible>flow1</SharedVarible>
</Flow2>
</Data> |
1) The first output message seems to be that the shared variable is not effected in ESQL coding but according to infocenter, shared variable can be changed at ESQL level:
Quote: |
With flow-shared variables (that is, those defined at the schema level), take care when multiple flows can update the variables, especially if the variable is being used as a counter. Likewise, with node-shared variables (that is, those defined at the module level), take care when multiple instances can update the variables.
|
2) In the secound output message, change in the shared variable taken place but Data.Flow2.SharedVariable = flow1, which is not expected.
Thanks,
Kevin |
|
Back to top |
|
 |
elvis_gn |
Posted: Tue Jul 18, 2006 1:41 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi kevin_22,
You did not read the paragraph above in the inforcenter.
Quote: |
Shared variables can be used to implement an in-memory cache in the message flow, see Optimizing message flow response times. Shared variables have a long lifetime and are visible to multiple messages passing through a flow, see Long-lived variables. They exist for the lifetime of the execution group process, the lifetime of the flow or node, or the lifetime of the node’s SQL that declares the variable (whichever is the shortest). They are initialized when the first message passes through the flow or node after each broker start up. |
Regards. |
|
Back to top |
|
 |
kevin_22 |
Posted: Tue Jul 18, 2006 2:54 am Post subject: |
|
|
 Centurion
Joined: 08 Mar 2005 Posts: 100
|
Hi elvis_gn,
elvin_gn
Quote: |
shared variables exist for the lifetime of the execution group process, the lifetime of the flow or node, or the lifetime of the node’s SQL that declares the variable (whichever is the shortest). |
To my understanding from the above statement,the scope of set share1 = 'flow2'; of Flow1 expires after the flow1 and this statement doesn't seems to effect for flow2 which seems to be true from the output.
Flow1 ESQL:
Quote: |
SET OutputRoot.Properties.MessageFormat = 'XML';
SET OutputRoot.XML.Data.Flow1.SharedVarible = share1;
set share1 = 'flow2';
SET OutputRoot.XML.Data.Flow1.SharedVar_Mod = share1;
Output message:
<Data>
<Flow1>
<SharedVarible>flow1</SharedVarible>
<SharedVar_Mod>flow2</SharedVar_Mod>
</Flow1>
<Flow2>
<SharedVarible>flow1</SharedVarible>
</Flow2>
</Data> |
But for the secound message the output is:
Quote: |
<Data>
<Flow1>
<SharedVarible>flow2</SharedVarible>
<SharedVar_Mod>flow2</SharedVar_Mod>
</Flow1>
<Flow2>
<SharedVarible>flow1</SharedVarible>
</Flow2>
</Data> |
Thanks,
Kevin |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Jul 18, 2006 3:02 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Did you read my previous post? If you want variables that span flows/execution groups etc you need to get the "cache" support pack.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kevin_22 |
Posted: Tue Jul 18, 2006 3:14 am Post subject: |
|
|
 Centurion
Joined: 08 Mar 2005 Posts: 100
|
|
Back to top |
|
 |
elvis_gn |
Posted: Tue Jul 18, 2006 3:15 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi kevin_22,
I'm totally confused in your SharedVarible, flow1 and flow2 Sorry,
Let me understand you correctly...you have two seperate flows and ur using the same input for both...can u paste only your input...and then the two outputs.
From the code I felt the shared variable was working as its supposed to be...the flow2 would give value of "flow1", since the flow1 has completed processing....
i believe, if the flow1 had not completed processing, then you would have got the value as "flow2" in the output, for the flow2.
And as fjb_saper proposed, you should try the cache support pack.
Regards. |
|
Back to top |
|
 |
shrek |
Posted: Tue Jul 18, 2006 3:30 am Post subject: |
|
|
 Acolyte
Joined: 19 Feb 2005 Posts: 61 Location: Gudivada,India
|
Shared Variables declared in a flow-specific module are available only for instances of that flow. We cannot access a shared variable declared in one flow from another.
However, you can do the following
1. Declare a shared variable in a subflow esql module and you will have separate instances of that variable from all main flows. Each instance of shared variable in main flow can inturn be accessed by other instances of the same flow.
2. Declare a shared variable in a common esql module and access the contents by invoking a function or procedure in that common module from your main flow.
Thanks. |
|
Back to top |
|
 |
kevin_22 |
Posted: Tue Jul 18, 2006 3:41 am Post subject: |
|
|
 Centurion
Joined: 08 Mar 2005 Posts: 100
|
Hi elvis_gn,
elvis_gn wrote:
Quote: |
Let me understand you correctly...you have two seperate flows and ur using the same input for both...can u paste only your input...and then the two outputs. |
Yes elvis_gn, you are right. There is nothing to do with the input as i am not copying the input message as you see in the ESQL code.infact i am putting some garbage input (BLOB) just to activate the Flow1.
elvis_gn wrote:
Quote: |
From the code I felt the shared variable was working as its supposed to be...the flow2 would give value of "flow1", since the flow1 has completed processing....
i believe, if the flow1 had not completed processing, then you would have got the value as "flow2" in the output, for the flow2. |
This is right for the first message( first garbage message i kept). But for the secound input message as you see Data.Flow1.SharedVariable = flow2 is not expected. It should be Data.Flow1.SharedVariable = flow1.
Please correct me if i am wrong.
Thanks,
Kevin
Last edited by kevin_22 on Tue Jul 18, 2006 4:17 am; edited 1 time in total |
|
Back to top |
|
 |
|
|
 |
Goto page 1, 2 Next |
Page 1 of 2 |
|
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
|
|
|
|