Author |
Message
|
jim777 |
Posted: Mon Feb 13, 2012 11:50 am Post subject: Is it possible to create a shared array in esql? |
|
|
Novice
Joined: 13 Feb 2012 Posts: 16
|
Hi guys, is it possible to create a shared array in ESQL that can be accessed from mulitple flows within an execution group.
The documentation talks about a shared character data type and that works great but I'm trying to setup a shared array/list of strings to be used, is this possible?
I see examples of setting up the list but only on the output message, I want to set some variables to that other flows within the execution group can see. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Feb 13, 2012 11:52 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
|
Back to top |
|
 |
adubya |
Posted: Mon Feb 13, 2012 11:53 am Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
The "widest" scope of an ESQL variable is at a flow level so multiple instances of a specific flow can share a variable but cross-flow sharing isn't supported natively in ESQL. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Feb 13, 2012 11:56 am Post subject: Re: Is it possible to create a shared array in esql? |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
jim777 wrote: |
The documentation talks about a shared character data type and that works great but I'm trying to setup a shared array/list of strings to be used, is this possible? |
I don't think the documentation talks about a shared character data type; IIRC it talks about a shared attribute of any data type. So if you were to identify a datatype capable of holding data in the form you describe, you could apply that attribute in the declare statement.
Given your comment that a shared character "works great", I would direct you to the scope of such a variable. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Feb 13, 2012 12:03 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
lancelotlinc wrote: |
Yes: using a Singleton or a solidDB in-memory database. |
Note the OP specifically asked "in ESQL". Correct me if I'm wrong, but you'd need to drop into Java to create a Singleton. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Feb 13, 2012 12:06 pm Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
|
Back to top |
|
 |
Vitor |
Posted: Mon Feb 13, 2012 12:07 pm Post subject: Re: Is it possible to create a shared array in esql? |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
jim777 wrote: |
I want to set some variables to that other flows within the execution group can see. |
You might also consider the infamous IA91 support pac - The Cache Node.
It may or may not fit your requirements. But it's an option. Possibly better than going into native Java (AFAIK there's Java in there somewhere). I advise you to look at the discussions on IA91 on this forum before deciding; not all of them are flattering. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Feb 13, 2012 12:11 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
lancelotlinc wrote: |
You are correct, Sir Vitor, however, the Singleton can be accessed from ESQL. |
Interesting; my Java knowledge increases (which isn't that tricky). So 2 questions:
- how do you populate the Singleton in ESQL?
- how so you access it in ESQL?
Code snippits would be nice. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Feb 13, 2012 12:27 pm Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
First, you create the Singleton code in a jar:
Code: |
private static class SingletonHolder {
public static final SingletonMain INSTANCE = new SingletonMain();
}
public static SingletonMain getInstance() {
return SingletonHolder.INSTANCE;
}
public static void addAGlobalValue( string someValueToAdd ){ ... }
|
Next, you access the Singleton from ESQL:
Code: |
CREATE PROCEDURE addAGlobalValue( IN report CHARACTER )
LANGUAGE JAVA
EXTERNAL NAME "com.<yourcompanyname>.middleware.common.util.SingletonMain.addAGlobalValue";
CALL addAGlobalValue( someData );
|
_________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
mgk |
Posted: Mon Feb 13, 2012 12:33 pm Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Quote: |
Hi guys, is it possible to create a shared array in ESQL that can be accessed from mulitple flows within an execution group. |
Yes, the ESQL ROW datatype is actually a tree and a tree can contain repeating elements, like an array, so a SHARED ROW will do what you need here, all within ESQL
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 |
|
 |
adubya |
Posted: Mon Feb 13, 2012 12:36 pm Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
mgk wrote: |
Quote: |
Hi guys, is it possible to create a shared array in ESQL that can be accessed from mulitple flows within an execution group. |
Yes, the ESQL ROW datatype is actually a tree and a tree can contain repeating elements, like an array, so a SHARED ROW will do what you need here, all within ESQL
Kind regards, |
Don't the scope rules stop the variable being shared between different flows though ? |
|
Back to top |
|
 |
mgk |
Posted: Mon Feb 13, 2012 12:40 pm Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Quote: |
Don't the scope rules stop the variable being shared between different flows though ? |
Yes
I did not notice that part of your original post, sorry. Given that a Java or .NET singleton would be a good alternative...
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 |
|
 |
Vitor |
Posted: Mon Feb 13, 2012 12:50 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
lancelotlinc wrote: |
First, you create the Singleton code in a jar:
Code: |
private static class SingletonHolder {
public static final SingletonMain INSTANCE = new SingletonMain();
}
public static SingletonMain getInstance() {
return SingletonHolder.INSTANCE;
}
public static void addAGlobalValue( string someValueToAdd ){ ... }
|
Next, you access the Singleton from ESQL:
Code: |
CREATE PROCEDURE addAGlobalValue( IN report CHARACTER )
LANGUAGE JAVA
EXTERNAL NAME "com.<yourcompanyname>.middleware.common.util.SingletonMain.addAGlobalValue";
CALL addAGlobalValue( someData );
|
|
So you don't create & access the Singleton from ESQL. You write some Java code, add that to a jar, load the jar into the broker and access the Java from ESQL. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Feb 13, 2012 12:53 pm Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Feb 13, 2012 10:20 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
lancelotlinc wrote: |
Yes, I'm sorry if I were not clear before. |
And there I thought that a properly formed singleton had some "synchronized" methods...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|