Nam Nguyen
Nam Nguyen

Reputation: 19

How to get the Broker's UUID, hostname, from an ESQL code running on an IBM IIB 10+?

How can we get the Broker's UUID, hostname, from an ESQL code running on an IBM IIB, version 10+?

(I could get the BrokerName from:

https://www.ibm.com/support/knowledgecenter/en/SSMKHH_9.0.0/com.ibm.etools.mft.doc/ak09512_.htm

but I don't seem to see anyway to access a Broker's UUID, hostname from an ESQL code running on an IBM IIB engine.)

Thanks in advance.

Upvotes: 0

Views: 2304

Answers (2)

TJA
TJA

Reputation: 3041

So when it comes to ESQL you can't get it. Which has irritated me for years, I mean why hide it.

If you are allowed to use Java Nodes then you can get it by calling the getUUID method of BrokerProxy.

BrokerProxy b = BrokerProxy.getLocalInstance("MYBROKER");
String b_uuid = b.getUUID();

If not then you can:

If you have scripted deploys then:

  • Add a mqsireportbroker command to it and scrape the UUID value
  • In the flow that needs the UUID value add a UDP(User Defined Property) UDP_BrokerUUID to it and set it to something like UNKNOWN
  • Then in your deploy script use mqsiapplybaroverride to change it to the scraped value.

Then there is IBM Integration API Exerciser which will show you how the API's work. install_dir\server\sample\IntegrationAPI\StartIntegrationAPIExerciser

Finally out of curiosity why do you need the Node UUID?

Caching

Goes something like this. Create a jar file similar to the one in @Daniels link. Note

DECLARE S_CacheRow SHARED ROW; -- Done at global level
CREATE COMPUTE MODULE DoingSomething
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
    CACHE: BEGIN ATOMIC
        IF NOT EXISTS(S_CacheRow.UUID[]) THEN
            SET S_CacheRow.BrokerUUID = GetBrokerUUID();
        END IF;
        SET Environment.BrokerUUID = S_CacheRow.BrokerUUID;
    END CACHE;
END;
END MODULE;

CREATE FUNCTION GetBrokerUUID() 
RETURNS CHAR 
LANGUAGE JAVA 
EXTERNAL NAME "mycompany.common.GetBrokerInfo.getBrokerUUID" 
;

import com.ibm.broker.config.proxy.*;

public class GetBrokerInfo {

    public static String getBrokerUUID() {

    BrokerProxy bp = null;
    try {
        bp = BrokerProxy.getInstance();   
    } catch (ConfigManagerProxyException ex) {
        System.out.println("Error connecting: " + ex);
    }

    String brokerUUID = '';
    if (bp != null) {
        brokerUUID = bp.getUUID();
        bp.disconnect();
    }  
    return brokerUUID;    
}

Please note I wrote this freehand and it's untested. But it does cover the salient points. You'll need to compile to a jar and put the jar in the shared classes folder typically /var/mqsi/shared-classes

Upvotes: 1

Daniel Steinmann
Daniel Steinmann

Reputation: 2199

Looking at the Accessible Properties page, the broker UUID and hostname is not available.

But you can get the broker UUID with a Monitoring Event; here a sample from the InfoCenter:

<wmb:messageFlowData>
   <wmb:broker wmb:UUID="d53122ae-1c01-0000-0080-b1b02528c6bf"
            wmb:name="myNode"/>
   <wmb:executionGroup wmb:UUID="d43122ae-1c01-0000-0080-b1b02528c6bf"
            wmb:name="default"/>
   <wmb:messageFlow wmb:UUID="e6d224ae-1c01-0000-0080-9100cd1a61f7"
            wmb:name="myMessageFlow" wmb:threadId="4201"
            wmb:uniqueFlowName="myNode.default.myApplication.myMessageFlow"/>
   <wmb:node wmb:nodeLabel="MQInput1" wmb:nodeType="ComIbmMqInputNode"
            wmb:terminal="in" wmb:detail="MYMESSAGEFLOW.IN"/>
</wmb:messageFlowData>

Upvotes: 0

Related Questions