Author |
Message
|
MbRick |
Posted: Mon Feb 09, 2009 1:18 pm Post subject: Retrieving server name at run time |
|
|
Newbie
Joined: 09 Feb 2009 Posts: 3
|
Hello All,
I am trying to retrieve the servername / hostname from within a message flow. This is the Windows server name, not the Broker name. Any method using ESQL or Java in a compute node would work.
Thanks,
WMB v6.1.0, Windows Server 2003 |
|
Back to top |
|
 |
Vitor |
Posted: Mon Feb 09, 2009 3:21 pm Post subject: Re: Retrieving server name at run time |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
MbRick wrote: |
I am trying to retrieve the servername / hostname from within a message flow. |
The question is, what's the requirement? If it's just environmental information probably better expressed as a UDP at deploy time. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
MbRick |
Posted: Mon Feb 09, 2009 5:18 pm Post subject: |
|
|
Newbie
Joined: 09 Feb 2009 Posts: 3
|
The requirement is to create a log record indicating time, date, server name, tracking id, and message body. This record is part of an existing tracing and diagnostic process used to monitor transactions being processed through a middleware application. The system has numerous brokers in the transformation layer and we need to know (using the server name in the tracelog record) what specific server processed the message.
I was hoping that the server name or host name was available as part of the environment tree at run time. I have seen code to retrieve the broker name, but not the server name. I have been searching the PDF manuals, redbooks and forums to no avail. You would think it would be an available property or variable accessible from the message flow.
Any help would be greatly appreciated. Thanks. |
|
Back to top |
|
 |
MQEnthu |
Posted: Mon Feb 09, 2009 8:09 pm Post subject: |
|
|
 Partisan
Joined: 06 Oct 2008 Posts: 329 Location: India
|
You can either use UDP as sugested by Vitor... set the server name before deploying. So that you can get the the server name for logging.
Otherwise, if I understand your scenario correctly,you have set of brokers (or each broker) associated with one server. Get the broker name dynamically and look for the corresponding server name. _________________ -----------------------------------------------
It is good to remember the past,
but don't let past capture your future |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Feb 09, 2009 8:49 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
MbRick wrote: |
The requirement is to create a log record indicating time, date, server name, tracking id, and message body. This record is part of an existing tracing and diagnostic process used to monitor transactions being processed through a middleware application. The system has numerous brokers in the transformation layer and we need to know (using the server name in the tracelog record) what specific server processed the message.
I was hoping that the server name or host name was available as part of the environment tree at run time. I have seen code to retrieve the broker name, but not the server name. I have been searching the PDF manuals, redbooks and forums to no avail. You would think it would be an available property or variable accessible from the message flow.
Any help would be greatly appreciated. Thanks. |
You are seriously mistaken in the importance you allocate to the host.
The broker name is everything. Through the broker name you should know the host name. What do you do when you have multiple brokers on the same host? And yes this answer is biased as it assumes that you have a well behaved network with no 2 broker names/qmgr names being the same.
Anyways if you really need the host name have you tried the stuff you can get at with java.net...
Code: |
InetAddress myaddress = InetAddress.getLocalHost();
String hostname = myaddress.getName(); // = myaddress.getCanonicalName(); |
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
smdavies99 |
Posted: Mon Feb 09, 2009 11:12 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Or you can use the Suport PAck that gets the environment variables node..... _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
MbRick |
Posted: Tue Feb 10, 2009 11:32 am Post subject: |
|
|
Newbie
Joined: 09 Feb 2009 Posts: 3
|
Thanks for the replies.
fjb_saper - The straight java code using
Code: |
InetAddress addr = InetAddress.getLocalHost(); |
does the trick for my current needs. If we had the option to add fields to our Tracelog record I could see adding BrokerName, ExecutionGroup and possibly MessageFlowName. Per your comment, this would give us a finer level of detail to help diagnose runtime issues.
smdavies99 - I will investigate the Support Pack option for future needs in where environment variables may be needed when using ESQL code.
Thanks again. |
|
Back to top |
|
 |
|