运城做网站哪家好,网站关键字可以做几个,标准企业网站开发合同,开发一个企业官网多少钱1、JMS是一个由AS提供的Message服务。它能接受消息产生者(Message Provider)所发出的消息#xff0c;并把消息转发给消息消费者(Message Consumer)。2、JMS提供2种类型的消息服务#xff1a;(1)Queue#xff0c;即点对点#xff0c;每一个消息仅仅转发给一个消息消费者使用… 1、JMS是一个由AS提供的Message服务。它能接受消息产生者(Message Provider)所发出的消息并把消息转发给消息消费者(Message Consumer)。2、JMS提供2种类型的消息服务(1)Queue即点对点每一个消息仅仅转发给一个消息消费者使用。(2)Topic即公布和订阅每一个消息能够转发给全部的订阅者(消费者)。3、WEBLOGIC 8下的JMS配置(1)配置JMS Connection Factory(2)配置JMS File Store(眼下所找到的文档都是配置File Store,事实上在详细的应用中可能JMS JDBC Store更广泛但临时没有找到资料)(3)配置JMS Server(4)在JMS Server的destinations中配置JMS Queue或者JMS Topic当中提供给消息产生者和消息消费者使用的是JMS Connection Factory的JNDI和JMS Queue或者JMS Topic的JNDI。4、消息产生者向JMS发送消息的步骤(1)使用JNDI查询对象JMS ConnectionFactory和Destination(JMS Queue/Topic)(2)使用管理对象JMS ConnectionFactory建立连接Connection(3)使用连接Connection 建立会话Session(4)使用会话Session和管理对象Destination创建消息生产者MessageSender(5)使用消息生产者MessageSender发送消息一个消息发送者的样例 package myjms; import java.util.*; import javax.naming.*; import javax.jms.*; public class MessageProducter { public static void main(String[] args) { String queueConnectionFactoryName myjmsconnectionfactory; //JMS Connection Factory的JNDI String queueName myjmsqueue; //JMS Queue或者JMS Topic的JNDI boolean transacted false;//transaction模式 int acknowledgementMode Session.AUTO_ACKNOWLEDGE;//acknowledgement模式 String messageMessage need to send;//模拟须要发送的消息 Properties properties new Properties(); properties.put(Context.INITIAL_CONTEXT_FACTORY,weblogic.jndi.WLInitialContextFactory); properties.put(Context.PROVIDER_URL, t3://localhost:7001); try { Context context new InitialContext(properties); Object obj context.lookup(queueConnectionFactoryName); QueueConnectionFactory queueConnectionFactory (QueueConnectionFactory) obj;//JMS Connection Factory的获得 obj context.lookup(queueName); Queue queue (Queue) obj;//JMS Queue或者JMS Topic的获得 QueueConnection queueConnectionqueueConnectionFactory.createQueueConnection();//产生连接 queueConnection.start(); QueueSession queueSession queueConnection.createQueueSession(transacted, acknowledgementMode); TextMessage textMessage queueSession.createTextMessage(); textMessage.clearBody(); textMessage.setText(message); QueueSender queueSender queueSession.createSender(queue); queueSender.send(textMessage); if (transacted) { queueSession.commit(); } if (queueSender ! null) { queueSender.close(); } if (queueSession ! null) { queueSession.close(); } if (queueConnection ! null) { queueConnection.close(); } } catch(Exception ex){ ex.printStackTrace(); } } } 5、消息消费者从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事件方法。一个消息消费者的样例 package myjms; import java.util.*; import javax.naming.*; import javax.jms.*; public class MessageReciever implements MessageListener { public void onMessage(Message message) { if (message instanceof TextMessage) { TextMessage textMessage (TextMessage) message; try { System.out.println(Message content is: textMessage.getText()); } catch (JMSException e) { e.printStackTrace(); } } } public static void main(String[] args) { MessageReciever msgRcvrnew MessageReciever(); String queueConnectionFactoryName myjmsconnectionfactory; String queueName myjmsqueue; boolean transacted false; int acknowledgementMode Session.AUTO_ACKNOWLEDGE; Properties properties new Properties(); properties.put(Context.INITIAL_CONTEXT_FACTORY, weblogic.jndi.WLInitialContextFactory); properties.put(Context.PROVIDER_URL, t3://localhost:7001); try { Context context new InitialContext(properties); Object obj context.lookup(queueConnectionFactoryName); QueueConnectionFactory queueConnectionFactory (QueueConnectionFactory) obj; obj context.lookup(queueName); Queue queue (Queue) obj; QueueConnection queueConnection queueConnectionFactory. createQueueConnection(); queueConnection.start(); QueueSession queueSession queueConnection.createQueueSession(transacted, acknowledgementMode); QueueReceiver queueReceiver queueSession.createReceiver(queue); queueReceiver.setMessageListener(msgRcvr); synchronized(msgRcvr){ msgRcvr.wait(100000); } if (queueReceiver ! null) { queueReceiver.close(); } if (queueSession ! null) { queueSession.close(); } if (queueConnection ! null) { queueConnection.close(); } } catch (Exception ex) { ex.printStackTrace(); } } } 6、Message-driven BeanMDB实际上就是一个消息消费者的client程序。它由AS EJB Container来管理。在JBUILDER生成一个MDB很easy。