|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Setting QMgrName from Environment variables in java |
« View previous topic :: View next topic » |
Author |
Message
|
nthepak |
Posted: Fri Aug 29, 2008 4:56 am Post subject: Setting QMgrName from Environment variables in java |
|
|
 Voyager
Joined: 19 Dec 2005 Posts: 79 Location: India
|
Hi all,
In the code below i am getting the queue manager and queue name values from the environment variables and storing it to the MbElement objects.
The problem is i need to convert them to strings to be able to set the Queue Name and Queue Manager Name using the lines like below - "MQQueueManager queueManager = new MQQueueManager(qmgrName);
MQQueue queue = queueManager.accessQueue(queueName, MQC.MQOO_OUTPUT);"
Below is my code snippet:
-------------------------------------------------------------------------------------
// Create the new outgoing message
MbMessage outMsg = new MbMessage(contact admin.getMessage());
MbMessage outLEnv = new MbMessage(contact admin.getLocalEnvironment());
MbMessage outEnv = new MbMessage(contact admin.getGlobalEnvironment());
MbMessage outExc = new MbMessage(contact admin.getExceptionList());
MbMessageAssembly outAssembly = new MbMessageAssembly(contact admin,outLEnv,outEnv,outMsg);
try {
// Get QueueManager and Queue names from the Environment variables
MbElement envElement = outAssembly.getGlobalEnvironment().getRootElement();
MbElement qmgrname = envElement.getFirstElementByPath("/Variables/qmgrName");
MbElement queuename = envElement.getFirstElementByPath("/Variables/queueName");
-------------------------------------------------------------------------------------
Since qmgrname and queuename are of type MbElement I need to convert this to string in order to set the MQQueueManager and MQQueue objects.
Can anybody tell me how we can do this since the objects only expect strings and what i have got is MbElement from the above method calls. _________________ BR,
Deepak N |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Aug 29, 2008 6:32 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
MBElement.getValue() or some such?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
DIPU@2007 |
Posted: Mon Sep 01, 2008 11:51 pm Post subject: Re: Setting QMgrName from Environment variables in java |
|
|
Novice
Joined: 13 Dec 2007 Posts: 18
|
nthepak wrote: |
Hi all,
In the code below i am getting the queue manager and queue name values from the environment variables and storing it to the MbElement objects.
The problem is i need to convert them to strings to be able to set the Queue Name and Queue Manager Name using the lines like below - "MQQueueManager queueManager = new MQQueueManager(qmgrName);
MQQueue queue = queueManager.accessQueue(queueName, MQC.MQOO_OUTPUT);"
Below is my code snippet:
-------------------------------------------------------------------------------------
// Create the new outgoing message
MbMessage outMsg = new MbMessage(contact admin.getMessage());
MbMessage outLEnv = new MbMessage(contact admin.getLocalEnvironment());
MbMessage outEnv = new MbMessage(contact admin.getGlobalEnvironment());
MbMessage outExc = new MbMessage(contact admin.getExceptionList());
MbMessageAssembly outAssembly = new MbMessageAssembly(contact admin,outLEnv,outEnv,outMsg);
try {
// Get QueueManager and Queue names from the Environment variables
MbElement envElement = outAssembly.getGlobalEnvironment().getRootElement();
MbElement qmgrname = envElement.getFirstElementByPath("/Variables/qmgrName");
MbElement queuename = envElement.getFirstElementByPath("/Variables/queueName");
-------------------------------------------------------------------------------------
Since qmgrname and queuename are of type MbElement I need to convert this to string in order to set the MQQueueManager and MQQueue objects.
Can anybody tell me how we can do this since the objects only expect strings and what i have got is MbElement from the above method calls. |
you have MbElement.toString() na..?? you can convert the object (MBElement) into string..!!! Try it Once...  |
|
Back to top |
|
 |
Esa |
Posted: Wed Sep 03, 2008 5:05 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
you can get the QM name like this:
getBroker().getQueueManagerName()
getBroker is a method of com.ibm.broker.javacompute.MBJavaComputeNode
BUT: MQ operations are supposed to be prohibited in a javacompute node. So you should not use MQ java API in a javacompute. MQ operations should be left to specialised nodes like MQOuput. Obviously, accessing MQ from within a javacompute node could easily break the transactional integrity of the message flow, which is the reason why it is not allowed.
Esa |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|