另外,我的客户端程序如下:
import javax.jms.*;
import javax.naming.*;
import java.util.*;
public class SimpleMessageClient {
    public static void main(String[] args) {
        Context jndiContext = null;
        ConnectionFactory connectionFactory = null;
        QueueConnection con = null;
        QueueSession session = null;
        QueueSender sender = null;
        Context ctx = null;        try {      Properties props =new Properties();
  props.setProperty("java.naming.factory.initial","weblogic.jndi.WLInitialContextFactory");
  props.setProperty("java.naming.provider.url","t3://192.168.2.163:8000");
  ctx =  new InitialContext(props);
        } catch (NamingException e) {
            System.out.println("上下文查找失败!" +e.toString());        }        try {
            //找到连接工厂
QueueConnectionFactory factory =(QueueConnectionFactory) ctx.lookup("jms/QueueConnectionFactory");
System.out.println("找到JMS连结工厂");
con = factory.createQueueConnection();
System.out.println("与JMS服务器取得连结");
session = con.createQueueSession(false,QueueSession.AUTO_ACKNOWLEDGE); System.out.println("取得连结会话对象"); Queue queue =(Queue) ctx.lookup("jms/fileQueue");
            System.out.println("找到消息目的地");            sender = session.createSender(queue);
            System.out.println("取得消息发送者对象");            TextMessage tmsg = session.createTextMessage();
            tmsg.setText("Hello World!我是王涛");
            sender.send(tmsg);
            System.out.println("消息成功发送!");
        } catch (NamingException e) {
            System.out.println("JNDI 查找异常 " + e.toString());        }catch(JMSException jse){  System.out.println("JMS异常 " + jse.toString());
}finally{
if(sender != null) try{ sender.close();}catch(JMSException e){}
if(session != null) try{ session.close();}catch(JMSException e){}
if(con != null) try{ con.close();}catch(JMSException e){}
if(ctx != null) try{ ctx.close();}catch(NamingException e){}
}
    }
}