Author |
Message
|
mymq |
Posted: Sat May 23, 2009 7:55 pm Post subject: To get the Broker name and Execution Name and HostName |
|
|
Centurion
Joined: 01 Mar 2007 Posts: 101 Location: US-Greenwille
|
Hi,
We are in the middle of migrating MB 5.0 to MB 6.1.0.3.
Most of our MB 5.0 message flows uses a common JAVA program to get the Broker name and Execution Name and HostName using the com.ibm.broker.plugin.MbNode class.
The code is below:
---------------------
import java.net.InetAddress;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
import com.ibm.broker.plugin.MbException;
import com.ibm.broker.plugin.MbNode;
public class MBUtils
{
public static MbNode mn = null;
public static String getBrokerName()
{
String brokername = "error";
try
{
if (mn == null)
{
mn = new MbNode();
}
brokername = mn.getBroker().getName();
}
catch (MbException e)
{
return brokername;
}
return brokername;
}
public static String getExecutionGroupName()
{
String executiongroup = "error";
try
{
if (mn == null)
{
mn = new MbNode();
}
executiongroup = mn.getExecutionGroup().getName();
}
catch (MbException e)
{
return executiongroup;
}
return executiongroup;
}
public static String getHostName()
{
String hostname = "error";
try
{
hostname = InetAddress.getLocalHost().getHostName();
}
catch (Exception ex)
{
return hostname;
}
return hostname;
}
}
The problem what i have is:
--------------------------------
1) The above java program is not getting compiled in MB6 environment.
2) I know, we have some ESQL function like "SQL.BrokerName" to get the broker name and through which we can replace the JAVA program. But, i will ended up with changing 100 of message flows which i dont want to do so.
So my question is>> If there a way where we can get the Broker name and Execution group name and host name thru JAVA program in MB6. If yes, could you please pass a sample code.
Please help me on the same. Thankx a lot inadvance. _________________ --SRK-- |
|
Back to top |
|
 |
mymq |
Posted: Sat May 23, 2009 9:10 pm Post subject: |
|
|
Centurion
Joined: 01 Mar 2007 Posts: 101 Location: US-Greenwille
|
Basically i am getting an error (instantiation error) during the run time :
mn = new MbNode(); _________________ --SRK-- |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat May 23, 2009 9:53 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Did you get back to the doc? What is the correct way of instantiating the MbNode class?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mqjeff |
Posted: Sun May 24, 2009 4:35 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
|
Back to top |
|
 |
fjb_saper |
Posted: Sun May 24, 2009 4:07 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Looking back at Jeff's nicely provided documentation link, you should change your class design to accept a reference to the current MbNode in the call.
So your call would look something like
Code: |
//from inside your JCN
String broker = MbUtils.getBrokerName(this);
//and in MbUtils:
public static String getBrokerName(MbNode curnode){
return curnode.getBroker().getName();
|
However given the ease of retrieving some of that stuff I don't see the point of creating an MbUtil class for this purpose...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
rekarm01 |
Posted: Mon May 25, 2009 3:39 pm Post subject: Re: To get the Broker name and Execution Name and HostName |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
mymq wrote: |
The problem what i have is:
--------------------------------
1) The above java program is not getting compiled in MB6 environment.
2) I know, we have some ESQL function like "SQL.BrokerName" to get the broker name and through which we can replace the JAVA program. But, i will ended up with changing 100 of message flows which i dont want to do so.
So my question is>> If there a way where we can get the Broker name and Execution group name and host name thru JAVA program in MB6. |
No. WMB v6 does not support instantiating MbNode (or MbJavaComputeNode) through static methods.
It looks like changing hundreds of message flows to use ESQL or a JCN is unavoidable. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon May 25, 2009 6:01 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Have you looked at the java code I posted above?
If you absolutely need the Mbnode you should be able to get it from the stack...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
rekarm01 |
Posted: Mon May 25, 2009 7:20 pm Post subject: Re: To get the Broker name and Execution Name and HostName |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
fjb_saper wrote: |
Code: |
//from inside your JCN
String broker = MbUtils.getBrokerName(this); |
Have you looked at the java code I posted above?
If you absolutely need the Mbnode you should be able to get it from the stack... |
Except that there is no "your JCN", and there is no "this". The original poster would have to first add a JCN to "hundreds of message flows", in order to use that code. It would be easier to just modify the ESQL to access the broker properties instead.
rekarm01 wrote: |
It looks like changing hundreds of message flows to use ESQL or a JCN is unavoidable. |
|
|
Back to top |
|
 |
mymq |
Posted: Wed May 27, 2009 7:57 pm Post subject: |
|
|
Centurion
Joined: 01 Mar 2007 Posts: 101 Location: US-Greenwille
|
rekarm01,
Thankx a lot.
are u saying that the options are:
1) Use Java node
2) Change the ESQL code.
No other options. Right?
Regards _________________ --SRK-- |
|
Back to top |
|
 |
rekarm01 |
Posted: Sun May 31, 2009 2:35 pm Post subject: Re: To get the Broker name and Execution Name and HostName |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
mymq wrote: |
are u saying that the options are:
1) Use Java node
2) Change the ESQL code. |
The options for accessing Broker properties are, in order from easiest to hardest: ESQL, JavaCompute node, Java custom node, or C custom node.
Broker properties are not accessible from Java routines that are called as ESQL functions or procedures. |
|
Back to top |
|
 |
er_pankajgupta84 |
Posted: Thu Feb 02, 2012 4:41 pm Post subject: |
|
|
 Master
Joined: 14 Nov 2008 Posts: 203 Location: charlotte,NC, USA
|
|
Back to top |
|
 |
kash3338 |
Posted: Thu Feb 02, 2012 5:18 pm Post subject: |
|
|
Shaman
Joined: 08 Feb 2009 Posts: 709 Location: Chennai, India
|
By using SQL.BrokerName you need not change all your 100 flows. I am sure you will be having a common procedure which invokes the Java program from ESQL currently, Just edit that procedure to return SQL.BrokerName instead of calling the Java program. |
|
Back to top |
|
 |
rekarm01 |
Posted: Thu Feb 02, 2012 10:36 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
er_pankajgupta84 wrote: |
I have posted a similar question today. |
There is a good reason to refer to old threads, rather than to re-open them ...
kash3338 wrote: |
By using SQL.BrokerName you need not change all your 100 flows. I am sure you will be having a common procedure which invokes the Java program from ESQL currently, Just edit that procedure to return SQL.BrokerName instead of calling the Java program. |
This is in response to an issue posted almost three years ago. It's very likely resolved by now.
According to the OP, using SQL.BrokerName would have required changing "100 of message flows". There was no common procedure which invoked the Java program from ESQL. |
|
Back to top |
|
 |
|