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 » To get the Broker name and Execution Name and HostName

Post new topic  Reply to topic
 To get the Broker name and Execution Name and HostName « View previous topic :: View next topic » 
Author Message
mymq
PostPosted: Sat May 23, 2009 7:55 pm    Post subject: To get the Broker name and Execution Name and HostName Reply with quote

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
View user's profile Send private message Send e-mail
mymq
PostPosted: Sat May 23, 2009 9:10 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Sat May 23, 2009 9:53 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Sun May 24, 2009 4:35 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/index.jsp?topic=/com.ibm.etools.mft.doc/ac30210_.htm

Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sun May 24, 2009 4:07 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
rekarm01
PostPosted: Mon May 25, 2009 3:39 pm    Post subject: Re: To get the Broker name and Execution Name and HostName Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Mon May 25, 2009 6:01 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
rekarm01
PostPosted: Mon May 25, 2009 7:20 pm    Post subject: Re: To get the Broker name and Execution Name and HostName Reply with quote

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
View user's profile Send private message
mymq
PostPosted: Wed May 27, 2009 7:57 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
rekarm01
PostPosted: Sun May 31, 2009 2:35 pm    Post subject: Re: To get the Broker name and Execution Name and HostName Reply with quote

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
View user's profile Send private message
er_pankajgupta84
PostPosted: Thu Feb 02, 2012 4:41 pm    Post subject: Reply with quote

Master

Joined: 14 Nov 2008
Posts: 203
Location: charlotte,NC, USA

I have posted a similar question today.

Have a look on this :[url] http://www.mqseries.net/phpBB2/viewtopic.php?t=60231[/url]

Technically its is doable to create an instance of MbJavaCompute node.

But I am not sure whether we should do it or not.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
kash3338
PostPosted: Thu Feb 02, 2012 5:18 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
rekarm01
PostPosted: Thu Feb 02, 2012 10:36 pm    Post subject: Reply with quote

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

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » To get the Broker name and Execution Name and HostName
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.