|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Can Send the Message but cannot receive it back |
« View previous topic :: View next topic » |
Author |
Message
|
harshmahey |
Posted: Mon Sep 22, 2003 1:36 pm Post subject: Can Send the Message but cannot receive it back |
|
|
Newbie
Joined: 26 Aug 2003 Posts: 5
|
Hi
Im using base java Classes for MQSeries .Im able to send the message to the Queue and also able to see the same in the MQ Explorer but when i try to retrieve it from the same queue using the messageid .It gives me NullPointer Exception.Please help.
Here is the code.
*****************************
package com;
import com.ibm.mq.*;
import java.io.*;
public class mqserieshandler {
public static void main(String[] args) {
init();
}
public static void init() {
MQQueueManager qMgr = null;
MQQueue sndQueue = null;
MQQueue rcvQueue = null;
String mqHostName = "CPQ10443900021";
String qMgrName = "QM_cpq10443900021";
int listenerPort;
String channelName = "S_cpq10443900021";
String reqQName = "default";
String respQName = "default";
String userID = "";
String userPWD = "";
// MQ Tracing.
boolean traceEnabled = false;
String traceFile = "c://tmp//mq.log";
int traceLevel = 5;
try
{
System.out.println("1");
MQEnvironment.hostname = mqHostName;
MQEnvironment.channel = channelName;
MQEnvironment.userID = userID;
MQEnvironment.password = userPWD;
MQEnvironment.properties.put(
MQC.TRANSPORT_PROPERTY,
MQC.TRANSPORT_MQSERIES);
qMgr = new MQQueueManager(qMgrName);
MQMessage sndMsg = new MQMessage();
int openOptions = MQC.MQOO_OUTPUT | MQC.MQOO_SET_IDENTITY_CONTEXT| MQC.MQOO_FAIL_IF_QUIESCING;
sndQueue = qMgr.accessQueue(reqQName, openOptions, qMgrName, null, null);
openOptions = MQC.MQOO_INPUT_SHARED;
try
{
rcvQueue = qMgr.accessQueue(respQName, openOptions, qMgrName, null, null);
}
catch(Exception exp)
{
System.out.println("Exception is "+exp);
}
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.options = MQC.MQPMO_NO_SYNCPOINT | MQC.MQPMO_SET_IDENTITY_CONTEXT | MQC.MQPMO_FAIL_IF_QUIESCING;
sndMsg = getMsg1();
sndQueue.put(sndMsg, pmo);
System.out.println("before recv msg");
receivemsg(sndMsg.messageId,respQName,openOptions, qMgrName);
System.out.println("after recv msg");
}
catch (Exception exp)
{
System.out.println("Exp" + exp);
}
}
public static void receivemsg(byte[] messageId,String respQName,int openOptions, String qMgrName)
{
MQQueueManager qMgr = null;
MQMessage rcvMsg = new MQMessage();
MQQueue rcvQueue = null;
try
{
System.out.println("aaaaa..4.."+messageId);
rcvMsg.correlationId = messageId;
System.out.println("aaaaa..41.."+messageId);
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.waitInterval = MQC.MQWI_UNLIMITED;
gmo.options = MQC.MQGMO_WAIT | MQC.MQGMO_FAIL_IF_QUIESCING | MQC.MQGMO_CONVERT;
System.out.println("aaaaa..42.."+messageId);
rcvQueue = qMgr.accessQueue(respQName, openOptions, qMgrName, null, null);
System.out.println("aaaaa..4..1");
rcvQueue.get(rcvMsg, gmo);
int msgLen = rcvMsg.getMessageLength();
System.out.println("aaaaa.." + msgLen);
}
catch (Exception exp)
{
System.out.println("aaaaa exp.." + exp);
}
}
public static MQMessage getMsg1()
{
MQMessage sndMsg = new MQMessage();
try
{
sndMsg.writeString("IIH ");
sndMsg.writeInt(1);
sndMsg.writeInt(84);
sndMsg.writeInt(0);
sndMsg.writeInt(0);
sndMsg.writeString("MQIMSVS ");
sndMsg.writeInt(0);
sndMsg.writeString(" "); // LTermOverride.
sndMsg.writeString(" "); // MFSMapName.
sndMsg.writeString("MQIMSVS "); // ReplyToFormat.
sndMsg.writeString("theMessage is the message"); // ReplyToFormat.
String theMessage = "this is a test msg";
sndMsg.writeString(sndMsg.toString()); // Pad a space for lu6.2.
System.out.println("4.1....." + sndMsg.toString());
}
catch (Exception exp)
{
}
return sndMsg;
}
}
*****************************
This is the log in getting
***************************
1
4.1.....com.ibm.mq.MQMessage@9075920
before recv msg
aaaaa..4..[B@1aca5920
aaaaa..41..[B@1aca5920
aaaaa..42..[B@1aca5920
aaaaa exp..java.lang.NullPointerException
after recv msg
****************************
When i see the message explorer i see the message in the "default"
Queue but im not able to receive it.
Please suggest. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Sep 23, 2003 4:58 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You should be explicitly catching MQExceptions in your receivemsg method in order to understand why the get is failing. |
|
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
|
|
|
|