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 » Dynamic ESQL and Dynamic Function Calling.

Post new topic  Reply to topic Goto page 1, 2  Next
 Dynamic ESQL and Dynamic Function Calling. « View previous topic :: View next topic » 
Author Message
SSachdeva
PostPosted: Tue Sep 07, 2004 7:42 am    Post subject: Dynamic ESQL and Dynamic Function Calling. Reply with quote

Apprentice

Joined: 04 Apr 2002
Posts: 33

Hi all,
I have a question about calling an ESQL Defined Function Dynamically. First let me explain what I want to do and then maybe anyone of you can tell me if this is possible.

I want to be able to define a whole bunch of utility functions in a project by itself. Then in my message flow (in some other project) ... I want to dynamically call these Utility functions:

I am thinking something like SET OUtputRoot.BLOB.BLOB = EVAL( 'FunctionName()' ); - Is this even possible?

One more requirement is that I if the code of the function changes - I only update the code of the function and redploy that - not every other message flow that is using that function. I know I can call a utility function from a message flow by simply refering the utility functions project in the message flow project - but in this case if I change the code of the utility function I have to redploy the message flow which is not what I am looking for.

For veteran C++ and Java developers what I am looking from ESQL is the ability to somewhat use reflection and the ability to define functions in somewhat of an internal DLL that can be changed on the fly. I hope I have managed to make myself clear - Not sure if ESQL can support such complex, dynamic function calling.

Thanks in advance,
Shammy
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jefflowrey
PostPosted: Tue Sep 07, 2004 7:43 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Why do you want to do this?

What is your requirement?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
SSachdeva
PostPosted: Tue Sep 07, 2004 8:03 am    Post subject: Reply with quote

Apprentice

Joined: 04 Apr 2002
Posts: 33

The requirement is that we abstract business logic functions from a message flow tat is processing mesasge from SAP. So no matter what the message type that comes into the flow - all we have to do is define the functions that need to be called on the incoming data, in a database. Then we inquire the database for the required functions to call those functions dynamically on the incoming data. So if we have to redeploy the same message flow every time we add a new function to our database and define it - it sorta defeats the purpose of the abstraction.

I hope this makes sense - its a little difficult to explain.

Thanks,
Shammy
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mgk
PostPosted: Tue Sep 07, 2004 8:08 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

I too am curious to know why you wish to do this. However, you can indeed use EVAL to dynamically construct a call to a function or procedure, even if the name of the routine you wish to invoke changes (for example) with each input message. What you cannot do is define a new function / procedure inside of an EVAL statement.

Just remember that excessive EVAL use will slow you down!

Cheers,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.


Last edited by mgk on Tue Sep 07, 2004 9:09 am; edited 1 time in total
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Sep 07, 2004 8:09 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

It does make sense.

Except for the whole part about trying to run business logic from Message Broker

Message Broker is for routing and translation, not for business logic.

Not that I haven't done business logic in Message Broker, but that's a different point.

You're much better off using broker to transform these messages into a fixed known internal format - like XML, and then writing a standalone process of some sort that will run the business logic on the XML.

You could, on the other hand, do this in a custom Java node.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
SSachdeva
PostPosted: Tue Sep 07, 2004 9:36 am    Post subject: Reply with quote

Apprentice

Joined: 04 Apr 2002
Posts: 33

So lets say that the logic still has to be done in WBIMB - is there any way for me to call a function defined in some other project (other than the project my message flow is in) from my mesage flow? - I tired defining a new Broker Schema and using the PATH Statement - but I dont think I am using this in the right context.

Thanks again,
Shammy
Back to top
View user's profile Send private message Send e-mail Visit poster's website
JT
PostPosted: Tue Sep 07, 2004 6:32 pm    Post subject: Reply with quote

Padawan

Joined: 27 Mar 2003
Posts: 1564
Location: Hartford, CT.

SSachdeva wrote:
...is there any way for me to call a function defined in some other project (other than the project my message flow is in) from my mesage flow?

It certainly appears as though you're on the right track:

Quote:
Functions
  • Functions are locally reusable and can be called by module-scope subroutines or mappings within the same schema.

  • Functions are globally reusable and can be called by other functions or procedures in ESQL or mapping files within any schema defined in the same or another project.

If you want to reuse functions or procedures globally:

  • Specify the path of the function or procedure:
    • If you want to reuse a function or procedure in an ESQL file, either provide a fully-qualified reference, or include a PATH statement that defines the path.

      If you choose to define the path, code the PATH statement in the same ESQL file as that in which the function is coded, but not within any MODULE.

  • Set up references between the projects in which the functions and procedures are defined and used.

SSachdeva wrote:
...but I dont think I am using this in the right context

What are the values you assigned to the Path clause & Broker Schema statement?
Back to top
View user's profile Send private message
SSachdeva
PostPosted: Wed Sep 08, 2004 4:28 am    Post subject: Reply with quote

Apprentice

Joined: 04 Apr 2002
Posts: 33

JT: thanks for the response - well heres what I did.

I created a project. In that project I created a new Broker schema under which there is only one ESQL file. I wrote all my reusable functions in that file. and saved/compiled it. I did not have any errors with this. Then I created a message flow project with one message flow. In the compute node - I want to call my reusable functions that I created in the other project via the compute node in the message flow project. I am thinking of the PATH statement somewhat like a import statement in Java - so the first line I put into my ESQL File is

PATH [ReusableFunctionsProjectName].[BrokerSchemaName]

then somewhere down in my code I call one of the functions in from my reusable functions. - I am pretty sure that what I am doing is wrong - but the documentation is not very clear about how to call the PATH statement. - Does any one have any examples on how to call the PATH statement?

Thanks,
Shammy
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mgk
PostPosted: Wed Sep 08, 2004 4:53 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Hi,

The PATH is a clause of the BROKER SCHEMA statement, so you use it something like this:

Code:
BROKER SCHEMA mySchema1 PATH mySchema2, mySchema3, mySchema4;


And so on, adding schemas as needed.

Bear in mind, you never HAVE to use a PATH statement, as you can always fully qualify a function call with a schema name explicitly. The PATH simply lets you not have to type the schema name explicitly each time you call the function.

EG.

If you have the following:

Code:
BROKER SCHEMA A1
CREATE FUNCTION F1() RETURNS INT RETURN 42;

BROKER SCHEMA A2
CREATE FUNCTION F2()  RETURNS INT
  RETURN A1.F1(); -- finds and calls F1 explicitly

BROKER SCHEMA A3 PATH A1;
CREATE FUNCTION F3() RETURNS INT
  RETURN F1(); -- finds calls calls A1.F1 via PATH


It is up to you to ensure that names do not clash if you use a PATH.

Cheers,
_________________
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
View user's profile Send private message
SSachdeva
PostPosted: Wed Sep 08, 2004 5:07 am    Post subject: Reply with quote

Apprentice

Joined: 04 Apr 2002
Posts: 33

Hi,
In this case - do i need to reference the project that has broker schema A1 in the project that has Broker Schema A2? - I have a project that with a broker schema defined called UTILITYSCHEMA. I also have another mesage flow project in which I am trying to call a function from UTILITYSCHEMA. (This project does not reference the project that contains UTILITYSCHEMA - cause I would like to be able to dynamically change the code in UTILITYSCHEMA - without haveing to redeploy my message flow project.) I call the function in my message flow project by using:

SET OUtputRoot.BLOB.BLOB = UTILITYSCHEMA.F1();

But I get an error saying that F1 is an incorrect routine name.

Shammy
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mgk
PostPosted: Wed Sep 08, 2004 5:20 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Hi,

This is not possible. You must reference each project that contains a schema from which you wish to call functions etc.

A redeploy will be needed when you change the utilityschema project.

How important is this level of dynamic function deployment / calling in your design?

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
View user's profile Send private message
SSachdeva
PostPosted: Wed Sep 08, 2004 5:24 am    Post subject: Reply with quote

Apprentice

Joined: 04 Apr 2002
Posts: 33

Its pretty important - I thought I could do this through ESQL - unfortunately - theres no way to get functionality of DLL from within WBIMB. I thought there may be a way to create some sort of a dynamically linked ESQL module that contained all the reusable functions that I needed. Well I guess its back to drawing board for me.

Thanks for all your help,
Shammy
Back to top
View user's profile Send private message Send e-mail Visit poster's website
moogoo
PostPosted: Wed Mar 01, 2006 12:44 pm    Post subject: Reply with quote

Acolyte

Joined: 20 Sep 2002
Posts: 54
Location: US

Just curious...I've been following this thread to also create an ESQL file that would be a repository for other message flows to access a common place for all function calls. I'd also like to be able to use Environment variables within these function calls to log the operation that is being invoked. In this case, it would look similar to mgk's example:

BROKER SCHEMA A1
CREATE FUNCTION F1() RETURNS INT
BEGIN
SET Environment.Variable = 'BLAH';
RETURN 42;
END;

However, upon compilation in v6.0, the statement with the Environment variable is flagged with a warning that "Identifier Environment cannot be resolved". Can Environment variables not be used in this context?

Thanks,

MG
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Mar 01, 2006 12:49 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You need, I believe, to pass the Environment in as a parameter.

If you search for PROCEDURE and Environment you might find the answer.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
mgk
PostPosted: Wed Mar 01, 2006 3:11 pm    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Hi,

Jeff is right. All the Correlation names (Environment, InputRoot etc) are effectively implicitly declared MODULE level variables, so non of them are in scope at SCHEMA level. Therefore, to use them at schema level, you have to pass them in by REFERENCE to the schema level FUNCTION or PROCEDURE that wants to use them.


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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Dynamic ESQL and Dynamic Function Calling.
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.