-
1. Re: how to display JMS client
adrian.brock Apr 23, 2003 7:51 PM (in response to minmin)This says the client closed the socket.
Did it crash?
Regards,
Adrian -
2. Re: how to display JMS client
minmin Apr 23, 2003 9:52 PM (in response to minmin)what is socket?I can't understand!
when I run the client file (below):
import javax.jms.*;
import java.io.*;
import java.net.*;
import javax.naming.*;
public class MsgListener {
private static final String QUEUE_CONN_FACTORY =
"ConnectionFactory";
private static final String QUEUE = "queue/B";
public static void main(String[] args) {
Context initCtx;
QueueConnectionFactory factory;
Queue queue;
QueueConnection conn;
QueueSession session;
QueueReceiver receiver;
TextMessage request;
try {
//Obtain an initial context
initCtx = new InitialContext();
//Lookup Connection Factory and Queue name
factory = (QueueConnectionFactory) initCtx.lookup(QUEUE_CONN_FACTORY);
queue = (Queue) initCtx.lookup(QUEUE);
//Create and start a Queue connection using the Factory
conn = (QueueConnection)factory.createQueueConnection();
conn.start();
//Open a Queue session on this connection
session = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
//Create a listener to receive messages from the Queue
receiver = session.createReceiver(queue);
//Send every message received to Standard Out
while (true) {
System.out.println("succeed all right?");
request = (TextMessage) receiver.receive();
System.out.println("Message Received: " + request.getText());
}
} catch (NamingException ne) {
ne.printStackTrace();
} catch (JMSException jms) {
jms.printStackTrace();
}
}
}
it always halt at the following sentence:
request = (TextMessage) receiver.receive();
when I force it to finish,the server(localhost) list series of errors ,that is the problem you answer.
what cause it and how to resolve the problem.