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 » Error while Receiving the message from local queue using JMS

Post new topic  Reply to topic
 Error while Receiving the message from local queue using JMS « View previous topic :: View next topic » 
Author Message
Deepak2003
PostPosted: Thu Aug 28, 2003 3:54 am    Post subject: Error while Receiving the message from local queue using JMS Reply with quote

Novice

Joined: 22 Aug 2003
Posts: 12

Hi

I am facing problems while receiving the message from local queue. i have MQ Series 5.2 setup on windows and running this code on the same machine using JMS :

The error i am getting is :
================================================================================
The attempt to read the message back again failed, apparently because it wasn't
there
javax.jms.JMSException: Failed to get message back again
at QReceiver1.main(QReceiver1.java:43)
===============================================
But i have two messages in my local queue ?

Here is the outline of my code which i am using to retrieve the message from queue :
+++++++++++++++++++++++++++++++++++++++++++++++
public static void main(String args[])
{
try
{
String factoryName="QCF2";
String queueName="Q3";

Context ctx = initJNDI(icf, url);

QueueConnectionFactory factory =(QueueConnectionFactory) ctx.lookup(factoryName);
Queue queue = (Queue) ctx.lookup(queueName);
ctx.close();
//create JMS objects
QueueConnection connection = factory.createQueueConnection();
QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
// code for receiving the message
QueueReceiver queueReceiver = session.createReceiver(queue);

Message inMessage = queueReceiver.receive(1000);

// Check to see if the receive call has actually returned a
// message. If it hasn't, report this and throw an exception...
if( inMessage == null ) {
System.out.println( "The attempt to read the message back again " +
"failed, apparently because it wasn't there");
throw new JMSException("Failed to get message back again");
}

// ...otherwise display the message
System.out.println( "\n" + "Got message"+": "+inMessage);

if( inMessage instanceof TextMessage ) {

// Extract the message content with getText()
String replyString = ((TextMessage) inMessage).getText();
throw new JMSException("Retrieved the wrong type of message");
}
// Closing QueueReceiver
queueReceiver.close();

// end of receive

connection.close();
} catch(Exception e){
e.printStackTrace();
System.exit(1);
}

}
+++++++++++++++++++++++++++++++++++++++++++++++

Please let me know if u have solution to fix the problem. will be really thankfull of you.

Regards
Deepak
Back to top
View user's profile Send private message
vennela
PostPosted: Thu Aug 28, 2003 7:17 am    Post subject: Reply with quote

Jedi Knight

Joined: 11 Aug 2002
Posts: 4055
Location: Hyderabad, India

Deepak:

How are you confirming that the messages are really there?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Deepak2003
PostPosted: Thu Aug 28, 2003 8:46 pm    Post subject: Reply with quote

Novice

Joined: 22 Aug 2003
Posts: 12

Hi

I am Good. How r u doing. i have physically 2 messages in the queue.
I am not able to trace where is the problem.
Is my code ok. or i need to add some other method.
I am stucked.

Regards
Deepak
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 » Error while Receiving the message from local queue using JMS
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.