消息生产者向JMS发送消息
消息产生者向JMS发送消息的步骤:
(1)使用JNDI查询对象JMS ConnectionFactory和Destination(JMS Queue/Topic)
(2)使用管理对象JMS ConnectionFactory建立连接Connection
(3)使用连接Connection 建立会话Session
(4)使用会话Session和管理对象Destination创建消息生产者MessageSender
(5)使用消息生产者MessageSender发送消息
消息消费者从JMS接受消息的步骤:
(1)使用JNDI查询对象JMS ConnectionFactory和Destination(JMS Queue/Topic)
(2)使用管理对象JMS ConnectionFactory建立连接Connection
(3)使用连接Connection 建立会话Session
(4)使用会话Session和管理对象Destination创建消息消费者MessageReceiver
(5)使用消息消费者MessageReceiver接受消息,需要用setMessageListener将MessageListener接口绑定到MessageReceiver
消息消费者必须实现了MessageListener接口,需要定义onMessage事件方法。
在myeclipse下测试实例

JMS Queue发送者

JMS Queue接收者

Topic 发送

Topic1接收

Topic 2接收

测试完成!
总结: 对javax.jms.*包及其类还不够了解,刚运行的时候总是提示找不到类,

后来查资料说classpath没配置好,排除了这个可能,后来查到了引起这个错误的三种可能:
1、缺少类,或者路径不对。
2、环境变量未配置正确,
3、程序里的jar包和weblogic自带的jar包版本不同。
我的是weblogic包与服务器的不同。
一直不是很清楚 t3://localhost:7001中的t3,只知道类似于http协议,多番查找后了解。
T3也称为丰富套接字,是BEA内部协议,功能丰富,可扩展性好。T3是多工双向和异步协议,经过高度优化,只使用一个套接字和一条线程。借助这种方法,基于Java的客户端可以根据服务器方需求使用多种RMI对象,但仍使用一个套接字和一条线程。