Author |
Message
|
dvishu78 |
Posted: Thu Oct 26, 2006 2:50 am Post subject: eroor in reading a message from a MQ queue |
|
|
Novice
Joined: 15 Jun 2006 Posts: 20 Location: INDIA
|
Hi all,
iam trying to read a mesage from MQ queue but iam getting
error
caused by: java.lang.NoSuchMethodError: com.ibm.mq.MQMsg2: method getMessageData()[B not found
at com.ibm.mq.jms.MQJMSMessage.createJMSMessage(MQJMSMessage.java:601)
at com.ibm.mq.jms.MQMessageConsumer.getMessageQ(MQMessageConsumer.java:1740)
at com.ibm.mq.jms.MQMessageConsumer.getMessage(MQMessageConsumer.java:4301)
at com.ibm.mq.jms.MQMessageConsumer.receiveInternalQ(MQMessageConsumer.java:2407)
at com.ibm.mq.jms.MQMessageConsumer.receiveQ(MQMessageConsumer.java:2158)
at com.ibm.mq.jms.MQMessageConsumer.receive(MQMessageConsumer.java:4210)
iam using MQseries6.0 and WAS6.0
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.QueueReceiver;
import javax.jms.Session;
import javax.jms.TextMessage;
import com.ibm.mq.jms.JMSC;
import com.ibm.mq.jms.MQQueueConnection;
import com.ibm.mq.jms.MQQueueConnectionFactory;
import com.ibm.mq.jms.MQQueueSession;
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Receiver {
private static String mqHostname = "EGLALPAR.IN.IBM.COM"; //MQ hostname
private static String mqChannel = "TGT_QM.EU5Q"; //MQ channel
private static String mqPort = "1414"; //MQ port
private static String mqQManager = "TGT_QM"; //MQ queue manager
private static String mqInputQueue = " IBM.GDMS.AIX.DOCGDMSR"; //MQ input queue used for
private static String mqOutputQueue = ""; //MQ output queue used for
public static void main(String[] args) throws JMSException {
MQQueueConnectionFactory qconFact;
MQQueueConnection qcon ;
MQQueueSession qsession;
QueueReceiver qreceiver ;
MQMessageConsumer mqcon;
Queue queue;
TextMessage msg = null;
try{
qconFact = new MQQueueConnectionFactory();
((MQQueueConnectionFactory)qconFact).setQueueManager(mqQManager);
((MQQueueConnectionFactory)qconFact).setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
((MQQueueConnectionFactory)qconFact).setHostName(mqHostname);
//((MQQueueConnectionFactory)qconFact).setChannel(mqChannel);
((MQQueueConnectionFactory)qconFact).setPort(Integer.parseInt(mqPort));
qcon = (MQQueueConnection) qconFact.createQueueConnection();
qsession = (MQQueueSession)qcon.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
queue = qsession.createQueue(mqInputQueue);
qreceiver = qsession.createReceiver(queue);
qcon.start(); msg = (TextMessage) qreceiver.receive();
String rmsg ;
if(msg instanceof TextMessage){
rmsg =((TextMessage)msg).getText();
System.out.print("Received message"+rmsg.toString());
}
qreceiver.close();
qsession.close();
qcon.close();
}
catch (JMSException je) {
System.out.println("caught JMSException: " + je);
}
}
}
please guide me
thanks in advance |
|
Back to top |
|
 |
Vitor |
Posted: Thu Oct 26, 2006 2:53 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Is there a linked exception with an MQ reason code in it? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
dvishu78 |
Posted: Thu Oct 26, 2006 4:00 am Post subject: eroor in reading a message from a MQ queue |
|
|
Novice
Joined: 15 Jun 2006 Posts: 20 Location: INDIA
|
Hi vitor
no there is linked EXception MQ reason code
thanks |
|
Back to top |
|
 |
Vitor |
Posted: Thu Oct 26, 2006 4:18 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Interesting and unusual. Still, I'm not a particually strong Java person so what do I know.
The absence of an MQ reason code implies you have a straightforward Java problem which I'm not really qualified to talk about (see above re my Java knowlege). I'll offer the usual paliative like check your CLASSPATH etc, but you need someone with more Java than me. Undoubtably such a person will be along in a minute.
Odd there's no MQ code though...  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Oct 26, 2006 4:24 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
To enhance my knowledge (training in Java being rather hard to obtain), how does your code check for a linked exception? Previously I've seen constructions like:
Code: |
catch (JMSException e){
System.out.println("Exception occurred: " +e.toString());
Exception ex = e.getLinkedException();
if(ex!=null)
System.out.println("Linked Exception is : "+ex);
} |
I notice this is missing from your code. How do you obtain the same result?
I thank you in advance for assistance in this matter. More a C coder personally....  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Oct 26, 2006 4:36 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
Vitor |
Posted: Thu Oct 26, 2006 4:54 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Allow me to clarify - budget for training in Java being rather hard to obtain. Are you suggesting I divert some of my meger daily rate towards funding this myself?? Isn't that one of the deadly sins or something??
So I took the oppertunity to ask a newbie Java question that I could have answered in two minutes if I'd looked. Turnabout is fair play I say  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Oct 26, 2006 5:24 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Java Tutorial is free... and it worked for me...  _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
dvishu78 |
Posted: Thu Oct 26, 2006 5:35 am Post subject: eroor in reading a message from a MQ queue |
|
|
Novice
Joined: 15 Jun 2006 Posts: 20 Location: INDIA
|
Hi Vitor,
later i added the code to get linked exception but not getting the Reason code i too feel strange iam able to connect
Iam getting that error when the below statement is executed
msg = (TextMessage) qreceiver.receive(); |
|
Back to top |
|
 |
Vitor |
Posted: Thu Oct 26, 2006 5:56 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
jefflowrey wrote: |
Java Tutorial is free... and it worked for me...  |
The difference in our intelectual level should be apparent by now.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Oct 26, 2006 6:01 am Post subject: Re: eroor in reading a message from a MQ queue |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
dvishu78 wrote: |
Hi Vitor,
later i added the code to get linked exception but not getting the Reason code i too feel strange iam able to connect
Iam getting that error when the below statement is executed
msg = (TextMessage) qreceiver.receive(); |
Well in the absence of an MQ problem (indicated by a reason code) and until I work through the tutorial jefflowrey kindly suggested I feel this is where I absent myself...  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Oct 26, 2006 6:46 am Post subject: Re: eroor in reading a message from a MQ queue |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
dvishu78 wrote: |
Hi all,
iam trying to read a mesage from MQ queue but iam getting
error
caused by: java.lang.NoSuchMethodError: com.ibm.mq.MQMsg2: method getMessageData()[B not found
......
please guide me
thanks in advance |
Careful reading of the error message should have said it all. Hence Jeff's remark on java training.
The method invoked getMessageData() is not part of the jms contract for a text message....
As I don't think you violated the jms contract and you state you are @version 6.0 I have only one question:
DID YOU APPLY THE FIXPACK?
Try it again @version 6.0.1.0
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
dvishu78 |
Posted: Fri Oct 27, 2006 4:12 am Post subject: error in reading a message from a MQ queue |
|
|
Novice
Joined: 15 Jun 2006 Posts: 20 Location: INDIA
|
Hi Saper,
when iam running the code the depth of the Queue is being reduced by 1 but iam not seeing the message and an error as above
yes we are using @version6.0 and i checked the jar file also we have the above claases
thanks |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Oct 27, 2006 4:15 am Post subject: Re: eroor in reading a message from a MQ queue |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
fjb_saper wrote: |
The method invoked getMessageData() is not part of the jms contract for a text message.... |
_________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
dvishu78 |
Posted: Fri Oct 27, 2006 4:18 am Post subject: eroor in reading a message from a MQ queue |
|
|
Novice
Joined: 15 Jun 2006 Posts: 20 Location: INDIA
|
Hi Saper,
thanks for ur reply
please suggest me what should I do |
|
Back to top |
|
 |
|