ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Problems accessing message tree with dynamic paths

Post new topic  Reply to topic
 Problems accessing message tree with dynamic paths « View previous topic :: View next topic » 
Author Message
WGerstma
PostPosted: Mon Jul 18, 2011 11:51 am    Post subject: Problems accessing message tree with dynamic paths Reply with quote

Acolyte

Joined: 18 Jul 2011
Posts: 55

Hi,

my real life scenario is very complex, so here a stripped down version of it.

I have a structure coming in via MRM Domain. I want to access elements in this MRM dynamically. The paths to look up elements are coming from outside, be it a user Defined Property or a database table. I thought an easy way to accomplish this was via the {} mechanism.

Here my sample:

<foo>
<bar>
<val1>x</val1>
<val2>y</val2>
</bar>
</foo>

The elements to be accessed are InputRoot.MRM.bar.val1 and InputRoot.MRM.bar.val2.

Here the sample code. With the debugger I can see that c becomes just null:

DECLARE path EXTERNAL CHAR 'bar.val1';

CREATE COMPUTE MODULE foo_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE c CHAR InputBody.{path};
RETURN TRUE;
END;
END MODULE;

When I modify this to:
DECLARE path1 EXTERNAL CHAR 'bar';
DECLARE path2 EXTERNAL CHAR 'val1';

CREATE COMPUTE MODULE foo_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE c CHAR InputBody.{path1}.{path2};
RETURN TRUE;
END;
END MODULE;

In this case the value 'x' is properly assigned to c.

My reallife scenario would have a path hierarchy of 6-10 levels and several other features like the [<] should be supported. Is there any possibility to "inject" the complete path via a single {} or do i have to split the path at the '.' and do terrible things with moving references down the message tree?

JAVA and XPath are both no options to resolve this puzzle.

Any suggestions welcome.
Back to top
View user's profile Send private message
WGerstma
PostPosted: Mon Jul 18, 2011 12:15 pm    Post subject: Reply with quote

Acolyte

Joined: 18 Jul 2011
Posts: 55

Just after i shut down my computer, it came to me that we long time ago used a terrible anti pattern of storing ESQL in the database and executing it via EVAL.

This works here as well:

DECLARE path EXTERNAL CHAR 'InputRoot.MRM.bar.val1';

CREATE COMPUTE MODULE foo_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE c CHAR;
EVAL('SET c = ' || path);
RETURN TRUE;
END;
END MODULE;

This should do it for the moment. However, EVAL is known for its bad performance. So any suggestions beyond are further very welcome.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Jul 18, 2011 12:25 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

WGerstma wrote:
Just after i shut down my computer, it came to me that we long time ago used a terrible anti pattern of storing ESQL in the database and executing it via EVAL.

This works here as well:

DECLARE path EXTERNAL CHAR 'InputRoot.MRM.bar.val1';

CREATE COMPUTE MODULE foo_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE c CHAR;
EVAL('SET c = ' || path);
RETURN TRUE;
END;
END MODULE;

This should do it for the moment. However, EVAL is known for its bad performance. So any suggestions beyond are further very welcome.


There are also some recursive algorithms that can be used looking for a field name and returning a reference to the field in question...?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Mon Jul 18, 2011 12:35 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Why are you interpreting XML with MRM rather than XMLNSC?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
WGerstma
PostPosted: Mon Jul 18, 2011 1:50 pm    Post subject: Reply with quote

Acolyte

Joined: 18 Jul 2011
Posts: 55

This was just a sample, in real life the feature should be used for any domain, supporting access to MRM, XMLNS and XMLNSC message trees. But I suppose 95% of our project are TDS MRM.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Problems accessing message tree with dynamic paths
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.