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 API Problem

Post new topic  Reply to topic
 JAVA API Problem « View previous topic :: View next topic » 
Author Message
nik_iway
PostPosted: Tue Nov 15, 2005 5:39 am    Post subject: JAVA API Problem Reply with quote

Centurion

Joined: 21 Jul 2005
Posts: 115

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=channel1
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 are the parameters in the properties.ini

CHANNEL_NAME = channel1
HOST_NAME =10.115.9.89
PORT = 1414
QUEUE_MANAGER = TEST
USER_ID = nik
PASSWORD = testsample

can anybody help me in this regard....

Waiting for reply and thanking you

Nik
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Nov 15, 2005 5:57 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

"channel1" is not the same as "CHANNEL1".
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
nik_iway
PostPosted: Tue Nov 15, 2005 6:16 am    Post subject: Reply with quote

Centurion

Joined: 21 Jul 2005
Posts: 115

Hi Jeff,
Do i need the change the name of the
CHANNEL_NAME = channel1

to

CHANNEL_NAME = CHANNEL

thats wat i have to do?
Thanks
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Nov 15, 2005 6:23 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You need to set the Channel property to the correct name of your channel, which is case-sensitive and very likely to be in all uppercase.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
nik_iway
PostPosted: Tue Nov 22, 2005 2:54 am    Post subject: Reply with quote

Centurion

Joined: 21 Jul 2005
Posts: 115

Hi Jeff,
I changed the channel name to CHANNEL1 but still I am getting the Same error MQRC 2059

I changed the configuration file like this

TEST
10.115.9.89
nik
1414
CHANNEL1
testsample

Iam getting error MQRC 2058

Can you please help me in this regard
Thanking you
Nik
Back to top
View user's profile Send private message
wschutz
PostPosted: Tue Nov 22, 2005 3:08 am    Post subject: Reply with quote

Jedi Knight

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

nik_iway wrote:
Hi Jeff,
I changed the channel name to CHANNEL1 but still I am getting the Same error MQRC 2059
......
Iam getting error MQRC 2058
So Nik, are you getting 2059 or 2058?
If it's 2058, the problem is that you are connecting to a queue manager whose name is NOT "TEST". Try leaving that out (ie, don't specify a qmgr name).
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
nik_iway
PostPosted: Tue Nov 22, 2005 4:17 am    Post subject: Reply with quote

Centurion

Joined: 21 Jul 2005
Posts: 115

Hi wschutz,
When i am trying to hard code the MQ Environment like below :

MQEnvironment.hostname = "10.115.9.89";
MQEnvironment.port = 1415;
MQEnvironment.channel="CHANNEL1";
MQQueueManager qMgr1 = new MQQueueManager("TEST");

The program is running fine

I dont want to hard code the MQ Configurations in my program i want it to be loaded from the .ini file . My .ini file is as below


QUEUE_MANAGER=TEST
HOST_NAME=10.115.9.89
USER_ID=nik
PORT=1415
CHANNEL_NAME=CHANNEL1
PASSWORD=testsample

Is there any other confguration that i am missing , do i need to do anything that i am missing in my Program. PLease do help me in this regard

Thanks
Nik
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Nov 22, 2005 4:19 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You have to write code to read your ini file, and then populate variables and then use those variables to populate the MQEnvironment.

I think one of the Sun Java Tutorials covers reading property files somewhere.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
nik_iway
PostPosted: Tue Nov 22, 2005 9:11 pm    Post subject: Reply with quote

Centurion

Joined: 21 Jul 2005
Posts: 115

Hi Jeff,

Does this peice of code read ini file, and then populate variables and then use those variables to populate the MQEnvironment.


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");


Is my code correct or i am missing something
Thanks
Nik
Back to top
View user's profile Send private message
nik_iway
PostPosted: Thu Nov 24, 2005 1:36 am    Post subject: Reply with quote

Centurion

Joined: 21 Jul 2005
Posts: 115

Hi Jeff,
I am running MQclient and Server in the Same Machine. I had
gone through the documentation it was mentioned that MQSERVER
needs to be set uo , so i did it by

SET MQSERVER = CHANNEL1\TCP\10.115.9.89(1414)

Even after that i am getting the error 2059

please do guide me in this regard
Thanking you
Nik
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Nov 24, 2005 6:44 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Java doesn't use the MQSERVER variable.
_________________
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 » JAVA API Problem
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.