Author |
Message
|
msunny |
Posted: Wed Jun 19, 2013 10:03 pm Post subject: 'Tried to access a non existent message' exception |
|
|
Novice
Joined: 07 Dec 2007 Posts: 18
|
Hi,
I am trying to initialized shared row variable for cache purposes at the very start of the messageflow. However as the flows reaches to compute node, exception occurs saying 'Tried to access a non existent message'. If I initialize the variable inside main, it works perfect, Please suggest. Thanks
Broker Version 8.0.0.2 |
|
Back to top |
|
 |
kash3338 |
Posted: Thu Jun 20, 2013 12:39 am Post subject: Re: 'Tried to access a non existent message' exception |
|
|
Shaman
Joined: 08 Feb 2009 Posts: 709 Location: Chennai, India
|
msunny wrote: |
If I initialize the variable inside main, it works perfect, Please suggest. |
Where else are you trying to initialize it? If this compute node is the first node, then this Main is the starting point where you need to do. |
|
Back to top |
|
 |
Esa |
Posted: Thu Jun 20, 2013 1:37 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
I guess you have two compute nodes, the first for initializing the SHARED variable and the second for accessing it.
I think you may get this exception if the compute modules are not in the same broker schema or if you are not accessing the variable with full path including the broker schema. |
|
Back to top |
|
 |
msunny |
Posted: Sun Jun 23, 2013 3:57 am Post subject: Re: 'Tried to access a non existent message' exception |
|
|
Novice
Joined: 07 Dec 2007 Posts: 18
|
kash3338 wrote: |
msunny wrote: |
If I initialize the variable inside main, it works perfect, Please suggest. |
Where else are you trying to initialize it? If this compute node is the first node, then this Main is the starting point where you need to do. |
I am trying to initialize at the schema level but getting the error.
BROKER SCHEMA mySchema
DECLARE statusesCache SHARED ROW;
DECLARE initMap SHARED BOOLEAN mySchema.initializeStatuses(); |
|
Back to top |
|
 |
msunny |
Posted: Sun Jun 23, 2013 4:06 am Post subject: |
|
|
Novice
Joined: 07 Dec 2007 Posts: 18
|
Esa wrote: |
I guess you have two compute nodes, the first for initializing the SHARED variable and the second for accessing it.
I think you may get this exception if the compute modules are not in the same broker schema or if you are not accessing the variable with full path including the broker schema. |
For simplicity purposes, I only have one compute node. ESQL file contains One Module and one initialization function outside module. If I call the function with schema inside the Main, it works fine but If i try to initialize at schema level, I get the 'Tried to access a non existent message' exception.
Below is the code:
BROKER SCHEMA mySchema
DECLARE statusesCache SHARED ROW;
DECLARE initMap SHARED BOOLEAN mySchema.initializeStatuses();
CREATE COMPUTE MODULE sharedVariablesInit_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- This line works if called
-- DECLARE localInitMap BOOLEAN mySchema.initializeStatuses();
CALL CopyEntireMessage();
RETURN TRUE;
END;
CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot = InputRoot;
END;
END MODULE;
CREATE FUNCTION initializeStatuses() RETURNS BOOLEAN
BEGIN
LOG EVENT VALUES('initializeStatuses CALLED');
ROUTING : BEGIN ATOMIC
LOG EVENT VALUES('In Atomic Bloc');
IF statusesCache.isMapLoaded IS NULL THEN
LOG EVENT VALUES('In If Bloc');
SET statusesCache.value_mapping[] =
(
SELECT vm.lookup_value_id, vm.value_id
FROM Database.value_mapping as vm WHERE vm.lookup_entity_id IN(46,49)
);
SET statusesCache.isMapLoaded = true;
END IF;
END ROUTING ;
LOG EVENT VALUES('initializeStatuses Ended');
RETURN TRUE;
END;
Events are logged upto 'In If Bloc'. After that exception occurred. |
|
Back to top |
|
 |
mqjeff |
Posted: Sun Jun 23, 2013 7:13 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
I would change the test on statusesCache.isMapLoaded IS NULL to check statusesCache or statusesCache.[] |
|
Back to top |
|
 |
Esa |
Posted: Sun Jun 23, 2013 11:02 pm Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
mqjeff wrote: |
I would change the test on statusesCache.isMapLoaded IS NULL to check statusesCache or statusesCache.[] |
Better even: IF NOT EXISTS(MySchema.statusesCache.value_mapping[])
@msunny: did you try
Code: |
SET mySchema.statusesCache.value_mapping[] = |
|
|
Back to top |
|
 |
rekarm01 |
Posted: Mon Jun 24, 2013 8:54 am Post subject: Re: 'Tried to access a non existent message' exception |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
msunny wrote: |
exception occurs saying 'Tried to access a non existent message'. |
What was the complete error message? A usertrace can provide that, and may also provide more useful information. |
|
Back to top |
|
 |
msunny |
Posted: Wed Jun 26, 2013 9:38 pm Post subject: Re: 'Tried to access a non existent message' exception |
|
|
Novice
Joined: 07 Dec 2007 Posts: 18
|
Thank you all for the help, I am able to execute the initialization function. The only problem remain is local variables data is not copied in shared variable so that I could use it in message flows. Please have a look. Thanks
Code: |
CREATE FUNCTION initializeStatuses() RETURNS BOOLEAN
BEGIN
LOG EVENT VALUES('initializeStatuses CALLED');
DECLARE tempStatus ROW;
ROUTING : BEGIN ATOMIC
LOG EVENT VALUES('In Routing Bloc');
IF statusesCache IS NULL THEN
LOG EVENT VALUES('In IF Bloc');
SET tempStatus.value_mapping[] =
(
SELECT vm.lookup_value_id, vm.value_id
FROM Database.value_mapping as vm WHERE vm.lookup_entity_id IN(46,49)
);
DECLARE size INT CARDINALITY(tempStatus.value_mapping[]);
LOG EVENT VALUES('Size: ' || CAST(size as CHAR));
-- I am unable to access these values in compute node. Also have tried it with schema name but no vain.
SET statusesCache.recordsCount = size;
SET statusesCache.value_mapping = tempStatus.value_mapping;
END IF;
END ROUTING ;
LOG EVENT VALUES('initializeStatuses Ended');
RETURN TRUE;
END; |
|
|
Back to top |
|
 |
lancelotlinc |
Posted: Thu Jun 27, 2013 2:59 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
|
Back to top |
|
 |
msunny |
Posted: Thu Jun 27, 2013 4:38 am Post subject: |
|
|
Novice
Joined: 07 Dec 2007 Posts: 18
|
lancelotlinc wrote: |
Why do you not use Environment.Variables tree ? |
statusesCache is shared variables to be used by all instances of messageflow, that's why I am trying to initialize it only first time. Also environment tree is not available at this level. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Thu Jun 27, 2013 11:06 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
msunny wrote: |
lancelotlinc wrote: |
Why do you not use Environment.Variables tree ? |
statusesCache is shared variables to be used by all instances of messageflow, that's why I am trying to initialize it only first time. Also environment tree is not available at this level. |
Why do you not use Global Cache ? _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
NealM |
Posted: Thu Jun 27, 2013 3:08 pm Post subject: |
|
|
 Master
Joined: 22 Feb 2011 Posts: 230 Location: NC or Utah (depends)
|
msunny, you said
Quote: |
...so that I could use it in message flows |
If you really meant that, that you wanted to access that shared row in various message flows, not just in multiple instances of the same flow, then you really should think about using the new global cache. |
|
Back to top |
|
 |
msunny |
Posted: Sat Jun 29, 2013 9:28 pm Post subject: |
|
|
Novice
Joined: 07 Dec 2007 Posts: 18
|
NealM wrote: |
msunny, you said
Quote: |
...so that I could use it in message flows |
If you really meant that, that you wanted to access that shared row in various message flows, not just in multiple instances of the same flow, then you really should think about using the new global cache. |
I haven't have tried global cache, actually I was looking for one message flow instances to share data but yes you are right this can expand to multiple flows and multiple applications. I will try this global cache onward. Thanks to All.
Just for curiosity I will still try to fill the shared variables at the initialization time. |
|
Back to top |
|
 |
|