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 » IBM MQ Java / JMS » Windows/Linux MQ Put Java Class

Post new topic  Reply to topic
 Windows/Linux MQ Put Java Class « View previous topic :: View next topic » 
Author Message
sigo
PostPosted: Mon Nov 07, 2005 3:22 pm    Post subject: Windows/Linux MQ Put Java Class Reply with quote

Newbie

Joined: 07 Nov 2005
Posts: 1

Newbie to the forum: PLEASE HELP!!

I have a specific situation that I am trying to work through. I have an MQ Server v 6.0 running on a Linux (Fedora Core 3) machine. I have a queuemanager, queue and listener configured (port 1414).

On my other machine I have windows XP with MQ Server v 6.0. I am running a Java class (see below) to put a message on a queue.
All this class is doing is creating a connection reading in a text file and dropping it on the queue on the linux machine. I created the identical environment to the linux machine on the windows box and was able to create the connection and send the text message properly. The error I get when trying to do a remote put is:
javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for '172.17.4.6:IDENTQM'
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:546)
at com.ibm.mq.jms.MQConnection.createQM(MQConnection.java:1450)
at com.ibm.mq.jms.MQConnection.createQMNonXA(MQConnection.java:960)
at com.ibm.mq.jms.MQQueueConnection.<init>(MQQueueConnection.java:159)
at com.ibm.mq.jms.MQQueueConnection.<init>(MQQueueConnection.java:77)
at com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueueConnectionFactory.java:142)
at mqSender.MQSender.sendMessages(MQSender.java:133)
at mqSender.MQSender.main(MQSender.java:43)


I have researched this and have found that this error is a connection issue with the queuemanager. I am certain that the queuemanager and queue are configured properly on the linux machine because the mqput program that comes with MQ is able to put a message on the queue and get it off afterwards.

In order to rule out a network issue I installed Eclipse on the linux machine and ran the class from the machine that the MQ server is running on and still got the same error. I am starting to think that the java class I have is wrong in someway. I have used similar classes in the past to pull and put messages from local queues but always on windows and I have yet to perform such tasks on linux.

Any assistance with my environment setup or with my Java would be greatly appreciated.







package mqSender;


import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.BufferedReader;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Vector;
import java.util.Hashtable;
import java.util.Enumeration;
import javax.jms.TextMessage;
import javax.naming.*;


public class MQSender {


private Vector outMessageFiles;
private Vector outMessages;
private String line;
private static String inMessageFileDirectory;
private static String inMessageFileName;

public static void main(String args[])
{
MQSender MQTest = new MQSender();
//MQTest.getMessageFileNames(sFilename);
MQTest.getMessages();
MQTest.sendMessages();
}

public MQSender()
{
super();
}


//=========================================================================
/** Get the names of the files containing the MQ messages
*/
private void getMessageFileNames(String filename)
{
File f = new File(filename);
if ( !f.exists() ) {
System.out.println("The messages file does not exist.");
System.exit(0);
}

outMessageFiles = new Vector();

try {
FileInputStream fstream = new FileInputStream(filename);
BufferedReader in = new BufferedReader(new InputStreamReader(fstream));
String line;

while ((line = in.readLine()) != null) {
outMessageFiles.add(line);
}
in.close();
fstream.close();

} catch (IOException e) {
System.out.println("There was an error reading the messages file: " + e.toString());
}

if ( outMessageFiles.size() == 0 ) {
System.out.println("The file does not list any message files.");
System.exit(0);
}
}

//=========================================================================
/** Get the messages from the message files
*/
private void getMessages()
{
String filename= "";
outMessages = new Vector();


StringBuffer message;

try {
FileInputStream fstream = new FileInputStream("C:/identTest1.txt");
BufferedReader in = new BufferedReader(new InputStreamReader(fstream));

line = in.readLine();
in.close();
fstream.close();

} catch (IOException e) {
System.out.println("There was an error reading the message file '" + filename + "': " + e.toString());
}
}

private void sendMessages()
{
//String channel = "identchannel";
String hostname="172.17.4.6";
String queueManager="IDENTQM";

try {

com.ibm.mq.jms.MQQueueConnectionFactory myMQ_QCF = new com.ibm.mq.jms.MQQueueConnectionFactory();

//System.out.println("***UPDATED CLASS*********" + queueSource + "/" + queueTarget);
// Set up the client connect information.
myMQ_QCF.setHostName(hostname);
myMQ_QCF.setTransportType(com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
//myMQ_QCF.setChannel(channel);
myMQ_QCF.setPort(1414);

System.out.println("Setting Queue Manager");
//set the q manager name
myMQ_QCF.setQueueManager(queueManager);

System.out.println("Creating Connection");

javax.jms.QueueConnection qConnect = myMQ_QCF.createQueueConnection();

qConnect.start();

System.out.println("Create Queue Session");
javax.jms.QueueSession queue_session = qConnect.createQueueSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);

System.out.println("Create Send Queue");

//create the send queue
javax.jms.Queue queueTest = queue_session.createQueue("CBPQUEUE");

System.out.println("Create Sender");
//create q sender
javax.jms.QueueSender qSenderTest = queue_session.createSender(queueTest);


//create text message
TextMessage message = queue_session.createTextMessage();
message.setText(line);

System.out.println("Send Message");
//send the message
qSenderTest.send(message);
System.out.println("MESSAGE SENT");
}
catch(Exception e)
{
System.out.println(e.getCause());
e.printStackTrace();
}

}
}
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Nov 07, 2005 3:58 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You should print the linked exception from your MQ Exceptions.

This will tell you the MQ Reason Code and Completion code for your failure.

I am betting you are getting either a 2059 or a 2035.
_________________
I am *not* the model of the modern major general.
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 » IBM MQ Java / JMS » Windows/Linux MQ Put Java Class
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.