System Message Queue 4.0 is starting everytime i run my client program
I am using SJSAS PE 9.0.
I have created a connection factory and queue using Admin console.
Whenever i try to run the client application to send or receive messges, System Message Queue is automatically starting.
Here is my program to access the message queue to send and receive message. But it is saying "Message Sent" and "No message found".
I have tried to run sender and receiver as differnt programs. But the same message is coming - No Message found.
I would like to know what's wrong with my process. Are messages really going? Then why i am not able to receive them?
By the way i am using Netbeans 5.5 to run the programs.
Any help will be appreciated very much.
Thanks,
Srikanth.
code --
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
public class SyncConsumer {
public static void main(String[] args) throws Exception {
InitialContext ctx = new InitialContext();
ConnectionFactory cf = (ConnectionFactory) ctx.lookup("QueueConnectionFactory");
Queue queue = (Queue) ctx.lookup("jms/queue");
Connection con = cf.createConnection();
Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(queue);
TextMessage message = session.createTextMessage();
message.setText("Hello");
producer.send(message);
System.out.println("Message Sent");
// read the message
MessageConsumer consumer = session.createConsumer(queue);
Message m = consumer.receive(100);
if (m != null)
System.out.println( "Reading message: " + m.toString());
else
System.out.println("No Message Found");
if (con != null) con.close();
}
}

