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 IndexIBM MQ Java / JMSSupportPac Java Classes - Windows

Post new topicReply to topic
SupportPac Java Classes - Windows View previous topic :: View next topic
Author Message
allord2
PostPosted: Thu Jul 19, 2001 2:28 pm Post subject: Reply with quote

Newbie

Joined: 15 May 2001
Posts: 4
Location: Montreal, Canada

Hi,

I installed the MA88 support pac for MQSeries Java support; follow the instructions to setup properly (e.g. CLASSPATH, PATH, etc.) and I wrote a sample Java application to connect to one of our Queue Manager.

I put some trace within the program and when it instantiate the qMgr object, I get the following error:

CC: 2, RC:2009

meanings that for some reason, I'm losing my connection with the Queue Manager. I haven't seen the error generated on the server-side (where the QM resides) and I would like to know if it is a common error.

TIA,

Alain
Back to top
View user's profile Send private message Send e-mail
kolban
PostPosted: Thu Jul 19, 2001 7:19 pm Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

Alain, is the queue manager to which you are connecting on the same machine as the Java program? If not, have you defined a SVRCONN MQSeries channel definition on the target queue manager? Have you defined a queue manager listener at a specific port? Have you specified the host-name or IP address plus port plus channel name in the MQEnvironment static members?

It might be useful to post some or all of the Java application you are testing to this topic and maybe we can spot a problem?
Back to top
View user's profile Send private message
allord2
PostPosted: Mon Jul 23, 2001 10:49 am Post subject: Reply with quote

Newbie

Joined: 15 May 2001
Posts: 4
Location: Montreal, Canada

Hi,

The QM is not on the same machine and there is already a SVRCONN defined and used by other PCs with a C-based pgm.

Therefore, the listener is already up & running on the server side. Using MQEnvironment variable, I've specified the the host-name or IP address plus port plus channel name. I've tried the pure IP address (e.g. 999.999.999.999) and the alias (e.g. xxxxxxxx) and none of them works.

Here is the listing of the program, which is quite simple. I intentionnaly removed the IP adress from this code but I'm sure that they are valid.

TIA,

Alain

import com.ibm.mq.*; // Include the MQ package
import java.io.*;
import java.lang.*;

public class MQHash {

private MQQueueManager qMgr;

/**********************************************************/
/* This program doesn't have any specific initialization. */
/* If it did, it could go here. */
/**********************************************************/
public void init() {
/* put specific initialization here.... */
System.out.println("----- Instantiation de MQHash -----");
}

public static void main (String args[]) {
System.out.println("----- Entre dans la mthode MAIN -----");


/****************************************************************/
/* Check to make sure that at least the queue name was entered. */
/****************************************************************/
if (args.length < 1) {
System.out.println("Required parameter missing - queue name");
} else {
MQHash mySample = new MQHash();
mySample.init();
mySample.start(args);
}
}

public void start(String args[]) {
try {
/*********************************************************/
/* Create a hash table to hold the MQSeries environment. */
/* Note: Change values to be appropriate. */
/*********************************************************/
System.out.println("----- Initialisation de la Hashtable -----");
java.util.Hashtable env = new java.util.Hashtable();
env.put(MQC.CHANNEL_PROPERTY, "XXXXXXXX");
/* env.put(MQC.HOST_NAME_PROPERTY, "XXXXXXXX"); */
env.put(MQC.HOST_NAME_PROPERTY, "999.999.999.999");
env.put(MQC.PORT_PROPERTY, new Integer(9999));

/********************************************************/
/* If a queue manager name was entered, then connect to */
/* it. Otherwise, use the default queue manager. */
/********************************************************/

System.out.println("----- Instantiation du Queue Manager -----");
if (args.length > 1) {
System.out.println("----- Les parametres suivants sont utilises: Qmgr: " + args[1] + " " + env);
qMgr = new MQQueueManager(args[1], env);
} else {
System.out.println("----- Les parametres suivants sont utilises: Qmgr = default "+ env);
qMgr = new MQQueueManager("", env);
}

/***********************************************************/
/* Open the queue, build the message, and put the message. */
/***********************************************************/

System.out.println("----- Ouverture de la queue -----");
int openOptions = MQC.MQOO_OUTPUT;
MQQueue myQueue = qMgr.accessQueue(args[0], openOptions,
null, null, null);

System.out.println("----- Creation/Ecriture du message -----");
MQMessage myMessage = new MQMessage();
myMessage.writeString("Environment set in hash table - TESTING ID");
myMessage.format = MQC.MQFMT_STRING;
myMessage.expiry = 300;

MQPutMessageOptions pmo = new MQPutMessageOptions();
myQueue.put(myMessage, pmo);

/**********************************************************/
/* Obtain the message from the queue and print it */
/**********************************************************/

System.out.println("----- Lecture du message de la queue -----");
MQMessage retrievedMessage = new MQMessage();
retrievedMessage.messageId = myMessage.messageId;

MQGetMessageOptions gmo = new MQGetMessageOptions(); // accept the defaults
myQueue.get(myMessage, gmo);

// And prove we have the message by displaying the UTF message text

String msgText = myMessage.readUTF();
System.out.println("----- The message is: " + msgText + " -----");

/**********************************************************/
/* Close the queue and disconnect from the queue manager. */
/**********************************************************/
myQueue.close();
qMgr.disconnect();
} catch (MQException ex) {
System.out.println("Une erreur MQSeries est survenue: " + ex.completionCode + " " +
ex.reasonCode);
} catch (java.io.IOException ex) {
System.out.println("Java exception: " + ex);
}
}
}


Back to top
View user's profile Send private message Send e-mail
kolban
PostPosted: Mon Jul 23, 2001 11:09 am Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

As a test, instead of populating and passing a Java HashTable object with the desired parameters ...


java.util.Hashtable env = new java.util.Hashtable();
env.put(MQC.CHANNEL_PROPERTY, "XXXXXXXX");
/* env.put(MQC.HOST_NAME_PROPERTY, "XXXXXXXX"); */
env.put(MQC.HOST_NAME_PROPERTY, "999.999.999.999");
env.put(MQC.PORT_PROPERTY, new Integer(9999));

Try setting the MQEnvironment static object's parameters directly and NOT use the HashTable constructor of MQQueueManager ...

eg.

MQEnvironment.channel = "XXXXXX";
MQEnvironment.port = 9999;
MQEnvironment.hostname = "XXXXXXXXX";
MQQueueManager m = new MQQueueManager();

Let me know what happens.
Back to top
View user's profile Send private message
allord2
PostPosted: Thu Jul 26, 2001 1:38 pm Post subject: Reply with quote

Newbie

Joined: 15 May 2001
Posts: 4
Location: Montreal, Canada

Hi,

Still the same results. I will ask to our UNIX admin to look at the Queue Manager level. In the meantime, is it possible to activate a trace with Java client? Does it works the same way as C client (e.g. log goes in AMQERRLOG file on the C: drive)

TIA for your help,

Alain
Back to top
View user's profile Send private message Send e-mail
kolban
PostPosted: Thu Jul 26, 2001 2:26 pm Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

See the following manual:

ftp://ftp.software.ibm.com/software/ts/mqseries/library/books/csqzaw07.pdf

See page 70 of this book for instructions on tracing. I would enable trace all the way up to level 5.
Back to top
View user's profile Send private message
UpkarSharma
PostPosted: Thu Aug 16, 2001 2:01 am Post subject: Reply with quote

Apprentice

Joined: 15 Aug 2001
Posts: 27
Location: Mumbai

Hi...
Please try this ... This program puts the message on the Queue and Retrieves it back ...



/**
* This application puts the message on a queue on Remote Machine for 10 seconds
* and takes back the message from the same queue.
* Remote Host Name = "atghp1"
* Remote Queue Manager = "QM_atghp1" - Queue Manager should be shared in a cluster.
* Remote Queue = "default"
* Channel name = "JAVA.CHANNEL" - This channel has to be a "Server Connection" channel.
* These names are case sensitive.
* Creation date: (10/05/2001 2:45:18 PM)
* @author: Upkar Sharma
*/

import com.ibm.mq.*; // Include the MQSeries classes for Java package.


public class Client1 {

private String hostname = "atghp1"; // Define the name of your host to connect to.

private String channel = "JAVA.CHANNEL"; // Define name of channel for client to use.

// Note. assumes MQSeries Server
// is listening on the default
// TCP/IP port of 1414.
/* If the MQ Series Server is listening on some other port then ....

private int port = port_number;

*/

private String qManager = "QM_atghp1"; // Define name of queue manager object to connect to.

private MQQueueManager qMgr; // define a queue manager object

//Constructor
public Client1 () {

// When the class is called, this initialization is done first.

// Set up MQSeries environment
MQEnvironment.hostname = hostname; // Could have put the
// hostname & channel
MQEnvironment.channel = channel; // string directly here!

// MQEnvironment.port="port";

MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY,//Set TCP/IP or server
MQC.TRANSPORT_MQSERIES); //Connection



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("QueueName to be put here",
qMgr.accessQueue("default",
openOptions,
null, // default q manager
null, // no dynamic q name
null); // no alternate user id

// 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 constant.

// put the message on the queue

system_default_local_queue.put(hello_world,pmo);
System.out.println("Message put on the queue");

// Put the message for 10 seconds.View the message on the queue.
Thread.sleep(10000);

// 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);
System.out.println("Message retrieved from the queue");

// 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();

} // End of try

// 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);
}

// Was it any other exception including java.lang.InterruptedException caused
// by Thread.sleep(10000) method.
catch (java.lang.Exception ex) {

System.out.println("An error occurred whilst writing to the message buffer: " + ex);
} // End of catch.

} // end of Constructor Client1.
// Define main method.
public static void main(String args []){
new Client1();
}
} // End of Class.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
dnaren
PostPosted: Mon Aug 27, 2001 9:53 pm Post subject: Reply with quote

Apprentice

Joined: 10 Aug 2001
Posts: 45
Location: Charlotte, NC

well, could you please edit the message and use
Code:
tag? The code looks very similar to the sample code in the 'Using Java' manual

The code doesn't compile anyway and won't run with missing 'port' numbers etc.

Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexIBM MQ Java / JMSSupportPac Java Classes - Windows
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.