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 » Java Program not connecting to MQSeries

Post new topic  Reply to topic
 Java Program not connecting to MQSeries « View previous topic :: View next topic » 
Author Message
Raghavan
PostPosted: Thu Nov 03, 2005 6:39 am    Post subject: Java Program not connecting to MQSeries Reply with quote

Newbie

Joined: 19 Sep 2005
Posts: 3

Hello,

Im a novice trying to run the following java program.


Code:

import java.io.*;
import java.util.*;
import com.ibm.mq.*;
import com.ibm.mq.jms.*;


public class Enqueue
{
      MQQueueManager qMgr            = null;
      com.ibm.mq.MQQueue payQ         = null;
      String   mqHostIp            =   "";
      String   mqPort               =   "";
      String   mqChannel            =   "";
      String   mqPayReciveQueueName   =   "";
      String   mqQueueManager         =   "";
      String   mqQueuePaySender      =   "";
      String   mqUserID            =   "";
      

   public static void main(String[] args) throws Exception
   {

      Enqueue enq = new Enqueue();
      //Send File Name with dir structure in args[1]
      //Send Payment No as args[0]
      String payno = args[0];
      String xml  = enq.parseStringFromFileAsString(args[1]);
      enq.sendXMLtoQueue(payno,xml);
   }

   public String checknull(String str){
      return(str == null ? "":str);
   }

   public void sendXMLtoQueue(String paymentRef, String inputXMLString) throws Exception
   {
         mqHostIp            =   "198.162.12.109";
         mqPort               =   "2620";
         mqChannel            =   "ENET_CHA";
         mqPayReciveQueueName   =   "STP_PAY_BULK_RESP";
         mqQueueManager         =   "ENET2UBS";
         mqQueuePaySender      =   "STP_PAY_REQ";
         mqUserID            =   "enet_mq_usr";
         
         System.out.println("Enqueue:sendXMLtoQueue() Property Initialization Done");
         MQEnvironment.hostname     = mqHostIp;
         MQEnvironment.port        = Integer.parseInt(mqPort);
         MQEnvironment.channel     = mqChannel;
         System.out.println("Enqueue:sendXMLtoQueue() MQEnvironment Initialization Done");

         qMgr                  = new MQQueueManager(mqQueueManager);               
         System.out.println("Enqueue:sendXMLtoQueue() Queue Manager Initialization Done");
         int openOptions            = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT ;
         System.out.println("Enqueue:sendXMLtoQueue() Open Options Initialized "+openOptions);
         payQ                  = qMgr.accessQueue(mqQueuePaySender,openOptions,  null, null, null);
         System.out.println("Enqueue:sendXMLtoQueue() Queue Initialized "+payQ);
         
         try{

         MQMessage msg= new MQMessage();
         msg.correlationId = paymentRef.getBytes();
         msg.replyToQueueName = mqPayReciveQueueName;
         msg.writeBytes(inputXMLString);
         System.out.println("Enqueue:sendXMLtoQueue() XML written to Message Object ");
         MQPutMessageOptions pmo = new MQPutMessageOptions();
         pmo.options=MQC.MQPMO_SYNCPOINT | MQC.MQMT_REPLY;
         payQ.put(msg,pmo);
         System.out.println("Enqueue:sendXMLtoQueue() Message sent to Queue ");
         }catch(Exception e)
         {
            System.out.println("Enqueue:sendXMLtoQueue() Exception When Sending Message "+e);
            qMgr.backout();

         }
   }


   public String parseStringFromFileAsString(String filename) throws Exception
   {

      String record="";
      RandomAccessFile rar =null;
            try{
               rar = new RandomAccessFile(filename,"rw");
               long flen = rar.length();
               int counter=0;
               while(true)
               {
                  record = checknull(rar.readLine());
                  long fp = rar.getFilePointer();
                  if(flen==fp)
                     break;
                  counter++;
               }
         

            }catch(Exception e)
            {
               System.out.println("Enqueue:parseStringFromFileAsString() Exception When reading file "+e);

            }finally
            {
               try{
                  if(rar!=null)
                  rar.close();
               }catch(Exception e)
               {
                  System.out.println("Enqueue:parseStringFromFileAsString() Exception When closing file "+e);
               }
            }
               return record;
      }   

}



The Program gives the following error

D:\raghav\projects\MQ>java Enqueue ft1111111111 ST_BD1_REQ.xml
Enqueue:sendXMLtoQueue() Property Initialization Done
Enqueue:sendXMLtoQueue() MQEnvironment Initialization Done
Unable to load message catalog - mqji
Exception in thread "main" com.ibm.mq.MQException: Completion Code 2, Reason 205
9
at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:
166)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11._createManagedConnecti
on(MQClientManagedConnectionFactoryJ11.java:196)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11.createManagedConnectio
n(MQClientManagedConnectionFactoryJ11.java:213)
at com.ibm.mq.StoredManagedConnection.<init>(StoredManagedConnection.jav
a:80)
at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConne
ctionManager.java:150)
at com.ibm.mq.MQQueueManager.obtainBaseMQQueueManager(MQQueueManager.jav
a:649)
at com.ibm.mq.MQQueueManager.construct(MQQueueManager.java:598)
at com.ibm.mq.MQQueueManager.<init>(MQQueueManager.java:375)
at Enqueue.sendXMLtoQueue(Enqueue.java:51)
at Enqueue.main(Enqueue.java:2


Can someone help me out ....
If i have failed to mention any other details, please tell me so that i can provide that also.
Thanks in advance

Rgds
Raghavan.V.
Back to top
View user's profile Send private message Yahoo Messenger
wschutz
PostPosted: Thu Nov 03, 2005 6:54 am    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

Use the search button for the reasons you might get a 2059 from a client program and then come back and tell us what you've tried to remedy your problem.
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Java Program not connecting to MQSeries
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.