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 » Is it possible to create a shared array in esql?

Post new topic  Reply to topic Goto page 1, 2  Next
 Is it possible to create a shared array in esql? « View previous topic :: View next topic » 
Author Message
jim777
PostPosted: Mon Feb 13, 2012 11:50 am    Post subject: Is it possible to create a shared array in esql? Reply with quote

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
View user's profile Send private message
lancelotlinc
PostPosted: Mon Feb 13, 2012 11:52 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

Yes: using a Singleton or a solidDB in-memory database.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
adubya
PostPosted: Mon Feb 13, 2012 11:53 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Vitor
PostPosted: Mon Feb 13, 2012 11:56 am    Post subject: Re: Is it possible to create a shared array in esql? Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Mon Feb 13, 2012 12:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
lancelotlinc
PostPosted: Mon Feb 13, 2012 12:06 pm    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

You are correct, Sir Vitor, however, the Singleton can be accessed from ESQL.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Mon Feb 13, 2012 12:07 pm    Post subject: Re: Is it possible to create a shared array in esql? Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Mon Feb 13, 2012 12:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
lancelotlinc
PostPosted: Mon Feb 13, 2012 12:27 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
mgk
PostPosted: Mon Feb 13, 2012 12:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
adubya
PostPosted: Mon Feb 13, 2012 12:36 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
mgk
PostPosted: Mon Feb 13, 2012 12:40 pm    Post subject: Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Mon Feb 13, 2012 12:50 pm    Post subject: Reply with quote

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
View user's profile Send private message
lancelotlinc
PostPosted: Mon Feb 13, 2012 12:53 pm    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

Yes, I'm sorry if I were not clear before.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Mon Feb 13, 2012 10:20 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
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 » Is it possible to create a shared array in esql?
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.