|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
RE: MQJE001: Completion Code 2, Reason 2097 |
« View previous topic :: View next topic » |
Author |
Message
|
ssajjadm |
Posted: Thu Nov 01, 2007 3:05 am Post subject: RE: MQJE001: Completion Code 2, Reason 2097 |
|
|
Newbie
Joined: 31 Oct 2007 Posts: 2
|
Hello all,
I am fairly new to MQseries and have been given a task to send a message to a remote queue using java(not jms).
the problem I am facing is that I could not sent the message's Identity context information which is a security requirement. i keep getting this error
MQJE001: Completion Code 2, Reason 2097
MQ exception occurred : Completion code 2 Reason code 2097
I am using MQSeries 6.0.1 and JDK 1.6.
could anyone help me as the resolution is very crucial for my project.
Here is the code..
import java.io.*;
import java.util.*;
import com.ibm.mq.*;
public class MQSender {
public static void main(String args[]) {
try {
String host = "159.55.113.252";
int port=1417;
String channel="LCL.DSERV.C1";
String qmName = "DIYNY01";
String qName = "DT.ERV.RECV";
MQSender mqSender = new MQSender(host,port,channel,qmName, qName);
mqSender.send("Test message at "+ new java.util.Date());
System.out.println("Terminado!");
} catch (MQException ex) {
MQSender.printEx(ex);
} catch (java.io.IOException ex) {
System.out.println("An error occurred reading from message buffer: " + ex);
}
}
Hashtable ht = null;
MQQueueManager qMgr=null;
MQQueue q=null;
public MQSender(String host, int port, String channel, String qmName, String qName) throws MQException{
// Set up MQSeries environment
MQEnvironment.hostname = host;
MQEnvironment.port = port;
MQEnvironment.channel = channel;
qMgr = new MQQueueManager(qmName);
// int openOptions = MQC.MQOO_OUTPUT;
// int openOptions = MQC.MQOO_SET_IDENTITY_CONTEXT;
// q = qMgr.accessQueue(qName, openOptions, null, null, null);
q = qMgr.accessQueue(qName, MQC.MQOO_OUTPUT+MQC.MQOO_SET_IDENTITY_CONTEXT);
}
public void send(String text) throws IOException, MQException{
MQMessage mBuf = new MQMessage();
MQPutMessageOptions pmo = new MQPutMessageOptions();
//pmo.options = MQC.MQPMO_NONE;
pmo.options = MQC.MQPMO_PASS_IDENTITY_CONTEXT;
pmo.contextReference = q;
mBuf.clearMessage();
mBuf.userId = "safjdjfd";
mBuf.accountingToken = "safjdjfd".getBytes();
mBuf.applicationIdData = "sajjadnnsasa";
mBuf.correlationId = MQC.MQCI_NONE;
mBuf.messageId = MQC.MQMI_NONE;
mBuf.writeUTF(text);
q.put(mBuf, pmo);
System.out.println("5");
}
public void close() throws MQException {
q.close();
qMgr.disconnect();
}
public static void printEx(MQException ex){
System.err.println("MQ exception occurred : Completion code " + ex.completionCode + " Reason code " + ex.reasonCode);
}
} |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Nov 01, 2007 3:14 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Look at the samples and read up in the Using java manual and the programmer's reference manual. Your PMO options are not right.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
ssajjadm |
Posted: Thu Nov 01, 2007 4:02 am Post subject: |
|
|
Newbie
Joined: 31 Oct 2007 Posts: 2
|
I am trying to read as much as i can but due to shortage of time and my inexperience of MQseries i couldnt figure out why its not working. The ibm site is suggesting it might be a bug.
http://www-1.ibm.com/support/docview.wss?uid=swg1IC47236
here is the updated version of the code:
import java.io.*;
import java.util.*;
import com.ibm.mq.*;
public class MQSender {
public static void main(String args[]) {
try {
String host = "159.55.113.252";
int port=1417;
String channel="LCL.DSERV.C1";
String qmName = "RBCNY1T";
String qName = "DTC.DSERV.RECV";
MQSender mqSender = new MQSender(host,port,channel,qmName, qName);
mqSender.send("Test message at "+ new java.util.Date());
System.out.println("Terminado!");
} catch (MQException ex) {
MQSender.printEx(ex);
} catch (java.io.IOException ex) {
System.out.println("An error occurred reading from message buffer: " + ex);
}
}
MQQueueManager qMgr=null;
MQQueue q=null;
a
public MQSender(String host, int port, String channel, String qmName, String qName) throws MQException{
// Set up MQSeries environment
MQEnvironment.hostname = host;
MQEnvironment.port = port;
MQEnvironment.channel = channel;
qMgr = new MQQueueManager(qmName);
q = qMgr.accessQueue(qName, MQC.MQOO_OUTPUT+MQC.MQOO_SET_IDENTITY_CONTEXT,qmName,null,null);
}
public void send(String text) throws IOException, MQException{
MQMessage mBuf = new MQMessage();
MQPutMessageOptions pmo = new MQPutMessageOptions();
//pmo.options = MQC.MQPMO_NONE;
pmo.options = MQC.MQPMO_PASS_IDENTITY_CONTEXT;
pmo.contextReference = q;
mBuf.clearMessage();
mBuf.userId = "usercheck";
mBuf.accountingToken = "userAT".getBytes();
mBuf.applicationIdData = "usercheck";
mBuf.writeUTF(text);
q.put(mBuf, pmo);
System.out.println("5");
}
public void close() throws MQException {
q.close();
qMgr.disconnect();
}
public static void printEx(MQException ex){
System.err.println("MQ exception occurred : Completion code " + ex.completionCode + " Reason code " + ex.reasonCode);
}
}
Your assistance is very appreciated |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Nov 01, 2007 2:05 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
What happens if you comment out this line:
pmo.contextReference = q; ?
I'm not sure that you can post without setting a user id with the options you set.
Enjoy
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|