另外,我的客户端程序如下:
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){}
}
}
}
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){}
}
}
}
解决方案 »
- sql server中我创建表时设了一个字段默认为getdate(),为什么总是1900-01-01,急呀?
- ireport问题
- 亲们,我是web初学者,在运行中报了这样一个错,跪求解
- spring 事务自动代理的问题
- struts中multibox的取值问题
- 50分求问题解决方法~!
- struts中的struts-form.tld怎么找不到a !!
- 求用JMF使用USB接口摄像头抓图像的java程序和相关资料(急)
- 一个java小问题,很容易拿分的,急!!!!!!!!!!!
- 有一个类是要实现对数据库中的表的数据的存取,有一句代码不知为什么这样写?
- 关于Jni性能和内存使用,请教各位
- 如何开发电子商务网站啊?十万火急!
<container-transaction>
<method>
<ejb-name>SimpleMDB</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>//Required改为Not Surpported或Not Required试一下