Error code 2195 when connect to MQ server by using XMSC MQ 9.1.0.5

46 views Asked by At

I try to connect to MQ server by using cmd tool with MQ 9.1.0.5 lib but get error code 2195 although I compared the configuration parameters with another tool running using jmsfactoryfactory(work well). Source code in below:

XMSC

 protected static IConnectionFactory MyCreateConnectionFactoryWMQ(MqConnectionInfo mqConnectionInfo)
 {
     try
     {
         // Create the connection factories factory
         XMSFactoryFactory factoryFactory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);

         // Use the connection factories factory to create a connection factory
         IConnectionFactory cf = factoryFactory.CreateConnectionFactory();

         // Set the properties
         cf.SetStringProperty(XMSC.WMQ_HOST_NAME, mqConnectionInfo.MQServer);
         cf.SetIntProperty(XMSC.WMQ_PORT, mqConnectionInfo.MQPort);
         cf.SetStringProperty(XMSC.WMQ_CHANNEL, mqConnectionInfo.MQChannel);
         cf.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, mqConnectionInfo.MQConnectionMode);
         //cf.SetIntProperty(XMSC.WMQ_CCSID, mqConnectionInfo.MQCCSID);
         //cf.SetIntProperty(XMSC.WMQ_BROKER_VERSION, XMSC.WMQ_BROKER_V1);
         
             cf.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, mqConnectionInfo.MQQueueManager);
         
         
         return (cf);
     }
     catch (XMSException ex)
     {
         Console.WriteLine("An IBM MQ error occurred: {0}", ex.ToString());
         return null;
     }

     catch (System.Exception ex)
     {
         Console.WriteLine("A System error occurred: {0}", ex.ToString());
         return null;
     }
 }


    protected static IDestination MyCreateDestination(ISession session, MqConnectionInfo mqConnectionInfo)
   {
       try
       {
           IDestination iDest;

           iDest = session.CreateQueue($"queue:///{mqConnectionInfo.QueueName}");  // Otherwise, default to creating a queue

           iDest.SetIntProperty(XMSC.DELIVERY_MODE, XMSC.DELIVERY_NOT_PERSISTENT);
           iDest.SetIntProperty(XMSC.WMQ_TARGET_CLIENT, XMSC.WMQ_CLIENT_NONJMS_MQ);

           return (iDest);
       }
       catch (XMSException ex)
       {
           Console.WriteLine("An IBM MQ error occurred: {0}", ex.ToString());
           return null;
       }

       catch (System.Exception ex)
       {
           Console.WriteLine("A System error occurred: {0}", ex.ToString());
           return null;
       }
   }             

JMS:

 JmsFactoryFactory jmsFactoryFactory = JmsFactoryFactory.getInstance("com.ibm.msg.client.wmq");
      JmsConnectionFactory jmsConnectionFactory = jmsFactoryFactory.createConnectionFactory();
      jmsConnectionFactory.setStringProperty("XMSC_WMQ_HOST_NAME", HOST);
      jmsConnectionFactory.setIntProperty("XMSC_WMQ_PORT", Integer.parseInt(PORT));
      jmsConnectionFactory.setStringProperty("XMSC_WMQ_CHANNEL", CHANNEL);
      jmsConnectionFactory.setIntProperty("XMSC_WMQ_CONNECTION_MODE", 1);
      jmsConnectionFactory.setStringProperty("XMSC_WMQ_QUEUE_MANAGER", QMGR);
      jmsConnectionFactory.setStringProperty("XMSC_WMQ_APPNAME", "JmsPutGet (JMS)");
      jmsConnectionFactory.setBooleanProperty("XMSC_USER_AUTHENTICATION_MQCSP", false);
      jmsConnectionFactory.setStringProperty("XMSC_USERID", APP_USER);
      jmsConnectionFactory.setStringProperty("XMSC_PASSWORD", APP_PASSWORD);
      jMSContext = jmsConnectionFactory.createContext();
      queue = jMSContext.createQueue("queue:///" + QUEUE_NAME);
      long l = System.currentTimeMillis() % 1000L;
      TextMessage textMessage = jMSContext.createTextMessage(strMessage);
      jMSProducer = jMSContext.createProducer();
      jMSProducer.send((Destination)queue, (Message)textMessage);

I tried to change some parameter but not work, hope those who have encountered this case will share information with me. Thanks

0

There are 0 answers