Topic
2 replies Latest Post - ‏2012-06-28T05:15:17Z by CharlesJohn
p_n_k
p_n_k
1 Post
ACCEPTED ANSWER

Pinned topic JAVA API Problem

‏2005-11-23T05:25:36Z |
Hi Everybody,
I am getting the following error when i am running my java client to access the MQServer (v 5.3)
  • listing properties --
QUEUE_MANAGER=TEST
HOST_NAME=10.115.9.89
USER_ID=nik
PORT=1414
CHANNEL_NAME=CHANNEL
PASSWORD=testsample

Connecting to queue manager: TEST
MQJE001: An MQException occurred: Completion Code 2, Reason 2059
MQJE011: Socket connection attempt refused
MQJE001: An MQException occurred: Completion Code 2, Reason 2059
MQJE011: Socket connection attempt refused
A WebSphere MQ Error occured : Completion Code 2 Reason Code 2059

My code is shown below

import java.text.*;
import java.io.*;
import java.util.*;
import java.lang.reflect.*;

import com.ibm.mq.*; //Include the WebSphere MQ classes for Java package
import com.ibm.mq.MQException;

public class mqput2
{

// define the name of the QueueManager
private static final String qManager = "TEST";
// and define the name of the Queue
private static final String qName = "requestQueue";
Properties properties = new Properties(); // Contains system settings.
// main method: simply call the runSample() method
public static void main(String args[])
{
new mqput2().runSample();
}

public void runSample() {
try
{

// Load system properties from file
FileInputStream fis = new FileInputStream ("C:\\nik\\properties.ini");
properties.load(fis);
fis.close();

// List system properties

ByteArrayOutputStream baos = new ByteArrayOutputStream();
properties.list(new PrintStream(baos));
System.out.println(baos.toString());

// Prepare MQ Series environment
String chl = properties.getProperty("CHANNEL_NAME");
String host = properties.getProperty("HOST_NAME");
String port = properties.getProperty("PORT");
String qmgr = properties.getProperty("QUEUE_MANAGER");
String UserId = properties.getProperty("USER_ID");
String Pwd = properties.getProperty("PASSWORD");

MQEnvironment.properties.put(MQC.HOST_NAME_PROPERTY, host);

MQEnvironment.properties.put(MQC.PORT_PROPERTY, port);

MQEnvironment.properties.put(MQC.CHANNEL_PROPERTY, chl);
PrintStream out1 = new PrintStream
(
new BufferedOutputStream
(
new FileOutputStream("C:\\nik\\cmqtrace.out")));

MQEnvironment.enableTracing(5, out1);

}
catch (Exception e)
{
e.printStackTrace();
}
try
{

//----------------------------------------------------------// Create a connection to the QueueManager
System.out.println("Connecting to queue manager:

"+qManager);
MQQueueManager qMgr = new MQQueueManager(qManager);

// Set up the options on the queue we wish to open
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF |

MQC.MQOO_OUTPUT;

// Now specify the queue that we wish to open and

the open options
System.out.println("Accessing queue: "+qName);
MQQueue queue = qMgr.accessQueue(qName,

openOptions);

// Define a simple WebSphere MQ Message ...
MQMessage msg = new MQMessage();
// ... and write some text in UTF8 format
msg.writeUTF("Hello, World!");

// Specify the default put message options
MQPutMessageOptions pmo = new MQPutMessageOptions();

// Put the message to the queue
System.out.println("Sending a message...");
queue.put(msg, pmo);

// Now get the message back again. First define a

WebSphere MQ message
// to receive the data
MQMessage rcvMessage = new MQMessage();

// Specify default get message options
MQGetMessageOptions gmo = new MQGetMessageOptions();

// Get the message off the queue.
System.out.println("...and getting the message back

again");
queue.get(rcvMessage, gmo);

// And display the message text...
String msgText = rcvMessage.readUTF();
System.out.println("The message is: " + msgText);

// Close the queue
System.out.println("Closing the queue");
queue.close();

// Disconnect from the QueueManager
System.out.println("Disconnecting from the Queue

Manager");
qMgr.disconnect();
System.out.println("Done!");
}
catch (MQException ex)
{
System.out.println("A WebSphere MQ Error

occured : Completion Code " + ex.completionCode + " Reason Code " + ex.reasonCode);
}
catch (java.io.IOException ex)
{
System.out.println("An IOException occured

whilst writing to the message buffer: "+ ex);
}
}
}

the following is the my properties .ini file

QUEUE_MANAGER=TEST
HOST_NAME=10.115.9.89
USER_ID=nik
PORT=1414
CHANNEL_NAME=CHANNEL
PASSWORD=testsample
can anybody help me in this regard....

Waiting for reply and thanking you

Nik
Updated on 2012-06-28T05:15:17Z at 2012-06-28T05:15:17Z by CharlesJohn
  • SystemAdmin
    SystemAdmin
    4447 Posts
    ACCEPTED ANSWER

    Re: JAVA API Problem

    ‏2005-11-28T20:05:55Z  in response to p_n_k
    I assume that there is no firewall between the client and the host running mqserver. Make sure you can ping the server first. Once that's confirmed, ensure that the listener is up and running on the port 1414 at host 10.115.9.89. You should be able to do a simple telnet to this port/host combination and see if connection is refused or granted.

    Govind Seshadri
    • CharlesJohn
      CharlesJohn
      1 Post
      ACCEPTED ANSWER

      Re: JAVA API Problem

      ‏2012-06-28T05:15:17Z  in response to SystemAdmin
      Hi,

      Can you please paste me the complete content of the program that you use to post message in MQ which is in different HOST ?

      Regards,