• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

MQWebsphere(MQJE001: An MQException occurred: Completion Code 2, Reason 2059)

 
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i trying to run MQSample class with MQ Websphere on windows xp.But i got Exception
MQJE001: An MQException occurred: Completion Code 2, Reason 2059

My Approch to run MQSample class is as follows

Step 1-:First i open dos panel and i run mq Queue manager by using following commands
strmqm
runmqsc
it gives message as follows

Starting MQSC for queue manager QM_sw12.

Step 2-: I start another dos panel and run program MQSample but it gives exception message as follows

Connecting to queue manager: QM_sw12
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

i have set all environment variables and i have also tested MQIVP class using same approch as shown above and it is working fine.

My MQSample code is-:
----------------------

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 MQSample {

// code identifier
public static final String sccsid = "@(#) javabase/samples/MQSample.java, java, j000, j000-L050412 1.10 05/04/06 16:40:38";

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

public void runSample() {

try
{

// Load system properties from file
FileInputStream fis = new FileInputStream("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");

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("mqtrace.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);
}
}
}
Thanks for help in advance.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to IBM/WebSphere...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!