|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Simple Java application fails with 2058 - def looks good |
« View previous topic :: View next topic » |
Author |
Message
|
sebastian |
Posted: Fri Dec 31, 2004 9:57 am Post subject: Simple Java application fails with 2058 - def looks good |
|
|
 Centurion
Joined: 12 Nov 2003 Posts: 110 Location: Philadelphia
|
I am trying to run a simple MQ java application from page 73 of the WMQ Using Java manual. The program compiles okay but when I try to run it, I get an error of 2058 - qmgr name error. The queue manager name looks correct to me. Our queue manager is named PR01U64D and this matches the java code.
Code attached:
I know that with some other Perl MQ scripts I wrote, I needed to define the MQSERVER set to a server connection channel. Do I need to do something similar with this code as well?
any feedback is appreciated,
Sebastian
// ======================================================================
// Licensed Materials - Property of IBM
// 5639-C34
// (c) Copyright IBM Corp. 1995, 1999
// ======================================================================
// MQSeries classes for Java sample application
//
// This sample runs as a Java application using the command :- java MQSample
import com.ibm.mq.*; // Include the MQSeries classes for Java package
public class MQSample
{
private String qManager = "PR01U64D"; // define name of queue
// manager to connect to.
private MQQueueManager qMgr; // define a queue manager
// object
public static void main(String args[]) {
new MQSample();
}
public MQSample() {
try {
// Create a connection to the queue manager
qMgr = new MQQueueManager(qManager);
// Set up the options on the queue we wish to open...
// Note. All MQSeries Options are prefixed with MQC in Java.
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF |
MQC.MQOO_OUTPUT ;
// Now specify the queue that we wish to open,
// and the open options...
MQQueue system_default_local_queue =
qMgr.accessQueue("SYSTEM.DEFAULT.LOCAL.QUEUE",
openOptions);
// Define a simple MQSeries message, and write some text in UTF format..
MQMessage hello_world = new MQMessage();
hello_world.writeUTF("Hello World!");
// specify the message options...
MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the // defaults,
// same as MQPMO_DEFAULT
// put the message on the queue
system_default_local_queue.put(hello_world,pmo);
// get the message back again...
// First define a MQSeries message buffer to receive the message into..
MQMessage retrievedMessage = new MQMessage();
retrievedMessage.messageId = hello_world.messageId;
// Set the get message options...
MQGetMessageOptions gmo = new MQGetMessageOptions(); // accept the defaults
// same as MQGMO_DEFAULT
// get the message off the queue...
system_default_local_queue.get(retrievedMessage, gmo);
// And prove we have the message by displaying the UTF message text
String msgText = retrievedMessage.readUTF();
System.out.println("The message is: " + msgText);
// Close the queue...
system_default_local_queue.close();
// Disconnect from the queue manager
qMgr.disconnect();
}
// If an error has occurred in the above, try to identify what went wrong
// Was it an MQSeries error?
catch (MQException ex)
{
System.out.println("An MQSeries error occurred : Completion code " +
ex.completionCode + " Reason code " + ex.reasonCode);
}
// Was it a Java buffer space error?
catch (java.io.IOException ex)
{
System.out.println("An error occurred whilst writing to the message buffer: " + ex);
}
}
} // end of sample _________________ sebastian signature |
|
Back to top |
|
 |
clindsey |
Posted: Fri Dec 31, 2004 10:08 am Post subject: |
|
|
Knight
Joined: 12 Jul 2002 Posts: 586 Location: Dallas, Tx
|
If you are running the code on the server, this code is ok. Queue manager names are case sensitive. Run 'dspmq' to double check the queue manager name.
If you are running on a client machine, you need to add
MQEnvironment.channel = "SYSTEM.DEF.SVRCONN";
MQEnvironment.hostname = "yourhostname";
MQEnvironment.port = yourportnumber;
before instantiating the queuemanager. Make sure you have a listener running on yourportnumber.
Charlie |
|
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
|
|
|
|