当前位置: 首页 > news >正文

三亚做网站的公司wordpress亿级数据库

三亚做网站的公司,wordpress亿级数据库,代理服务网站,网站开发什么意思带有ActiveMQ的JMS JMS是Java Message Service的缩写#xff0c;它提供了一种以松散耦合#xff0c;灵活的方式集成应用程序的机制。 JMS以存储和转发的方式跨应用程序异步传递数据。 应用程序通过充当中介的MOM#xff08;面向消息的中间件#xff09;进行通信#xff0c… 带有ActiveMQ的JMS JMS是Java Message Service的缩写它提供了一种以松散耦合灵活的方式集成应用程序的机制。 JMS以存储和转发的方式跨应用程序异步传递数据。 应用程序通过充当中介的MOM面向消息的中间件进行通信而无需直接通信。 JMS体系结构 JMS的主要组件是 JMS Provider一种消息传递系统它实现JMS接口并提供管理和控制功能 客户端发送或接收JMS消息的Java应用程序。 消息发送者称为生产者而接收者称为消费者 消息在JMS客户端之间传递信息的对象 受管对象管理员为使用客户端而创建的预配置JMS对象。 有几种JMS提供程序可用例如Apache ActiveMQ和OpenMQ。 在这里我使用了Apache ActiveMQ。 在Windows上安装和启动Apache ActiveMQ 下载ActiveMQ Windows二进制分发版 将其提取到所需位置 使用命令提示符将目录更改为ActiveMQ安装文件夹中的bin文件夹然后运行以下命令以启动ActiveMQ activemq 启动ActiveMQ之后您可以使用http// localhost8161 / admin /访问管理控制台并执行管理任务 JMS消息传递模型 JMS具有两种消息传递模型即点对点消息传递模型和发布者订户消息传递模型。 点对点消息传递模型 生产者将消息发送到JMS提供程序中的指定队列并且只有一个监听该队列的使用者才能接收该消息。 示例1和示例2几乎相似唯一的区别是示例1在程序内创建队列示例2使用jndi.properties文件命名查找和创建队列。 例子1 package com.eviac.blog.jms;import javax.jms.*; import javax.naming.InitialContext; import javax.naming.NamingException;import org.apache.log4j.BasicConfigurator;public class Producer {public Producer() throws JMSException, NamingException {// Obtain a JNDI connectionInitialContext jndi new InitialContext();// Look up a JMS connection factoryConnectionFactory conFactory (ConnectionFactory) jndi.lookup(connectionFactory);Connection connection;// Getting JMS connection from the server and starting itconnection conFactory.createConnection();try {connection.start();// JMS messages are sent and received using a Session. We will// create here a non-transactional session object. If you want// to use transactions you should set the first parameter to trueSession session connection.createSession(false,Session.AUTO_ACKNOWLEDGE);Destination destination (Destination) jndi.lookup(MyQueue);// MessageProducer is used for sending messages (as opposed// to MessageConsumer which is used for receiving them)MessageProducer producer session.createProducer(destination);// We will send a small text message saying Hello World!TextMessage message session.createTextMessage(Hello World!);// Here we are sending the message!producer.send(message);System.out.println(Sent message message.getText() );} finally {connection.close();}}public static void main(String[] args) throws JMSException {try {BasicConfigurator.configure();new Producer();} catch (NamingException e) {e.printStackTrace();}} }package com.eviac.blog.jms;import javax.jms.*;import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.log4j.BasicConfigurator;public class Consumer {// URL of the JMS serverprivate static String url ActiveMQConnection.DEFAULT_BROKER_URL;// Name of the queue we will receive messages fromprivate static String subject MYQUEUE;public static void main(String[] args) throws JMSException {BasicConfigurator.configure();// Getting JMS connection from the serverConnectionFactory connectionFactory new ActiveMQConnectionFactory(url);Connection connection connectionFactory.createConnection();connection.start();// Creating session for seding messagesSession session connection.createSession(false,Session.AUTO_ACKNOWLEDGE);// Getting the queueDestination destination session.createQueue(subject);// MessageConsumer is used for receiving (consuming) messagesMessageConsumer consumer session.createConsumer(destination);// Here we receive the message.// By default this call is blocking, which means it will wait// for a message to arrive on the queue.Message message consumer.receive();// There are many types of Message and TextMessage// is just one of them. Producer sent us a TextMessage// so we must cast to it to get access to its .getText()// method.if (message instanceof TextMessage) {TextMessage textMessage (TextMessage) message;System.out.println(Received message textMessage.getText() );}connection.close();} } jndi.properties # START SNIPPET: jndijava.naming.factory.initial org.apache.activemq.jndi.ActiveMQInitialContextFactory# use the following property to configure the default connector java.naming.provider.url vm://localhost# use the following property to specify the JNDI name the connection factory # should appear as. #connectionFactoryNames connectionFactory, queueConnectionFactory, topicConnectionFactry# register some queues in JNDI using the form # queue.[jndiName] [physicalName] queue.MyQueue example.MyQueue# register some topics in JNDI using the form # topic.[jndiName] [physicalName] topic.MyTopic example.MyTopic# END SNIPPET: jndipackage com.eviac.blog.jms;import javax.jms.*; import javax.naming.InitialContext; import javax.naming.NamingException;import org.apache.log4j.BasicConfigurator;public class Producer {public Producer() throws JMSException, NamingException {// Obtain a JNDI connectionInitialContext jndi new InitialContext();// Look up a JMS connection factoryConnectionFactory conFactory (ConnectionFactory) jndi.lookup(connectionFactory);Connection connection;// Getting JMS connection from the server and starting itconnection conFactory.createConnection();try {connection.start();// JMS messages are sent and received using a Session. We will// create here a non-transactional session object. If you want// to use transactions you should set the first parameter to trueSession session connection.createSession(false,Session.AUTO_ACKNOWLEDGE);Destination destination (Destination) jndi.lookup(MyQueue);// MessageProducer is used for sending messages (as opposed// to MessageConsumer which is used for receiving them)MessageProducer producer session.createProducer(destination);// We will send a small text message saying Hello World!TextMessage message session.createTextMessage(Hello World!);// Here we are sending the message!producer.send(message);System.out.println(Sent message message.getText() );} finally {connection.close();}}public static void main(String[] args) throws JMSException {try {BasicConfigurator.configure();new Producer();} catch (NamingException e) {e.printStackTrace();}} }package com.eviac.blog.jms;import javax.jms.*; import javax.naming.InitialContext; import javax.naming.NamingException;import org.apache.log4j.BasicConfigurator;public class Consumer {public Consumer() throws NamingException, JMSException {Connection connection;// Obtain a JNDI connectionInitialContext jndi new InitialContext();// Look up a JMS connection factoryConnectionFactory conFactory (ConnectionFactory) jndi.lookup(connectionFactory);// Getting JMS connection from the server and starting it// ConnectionFactory connectionFactory new// ActiveMQConnectionFactory(url);connection conFactory.createConnection();// // Getting JMS connection from the server// ConnectionFactory connectionFactory new// ActiveMQConnectionFactory(url);// Connection connection connectionFactory.createConnection();try {connection.start();// Creating session for seding messagesSession session connection.createSession(false,Session.AUTO_ACKNOWLEDGE);// Getting the queueDestination destination (Destination) jndi.lookup(MyQueue);// MessageConsumer is used for receiving (consuming) messagesMessageConsumer consumer session.createConsumer(destination);// Here we receive the message.// By default this call is blocking, which means it will wait// for a message to arrive on the queue.Message message consumer.receive();// There are many types of Message and TextMessage// is just one of them. Producer sent us a TextMessage// so we must cast to it to get access to its .getText()// method.if (message instanceof TextMessage) {TextMessage textMessage (TextMessage) message;System.out.println(Received message textMessage.getText() );}} finally {connection.close();}}public static void main(String[] args) throws JMSException {BasicConfigurator.configure();try {new Consumer();} catch (NamingException e) {// TODO Auto-generated catch blocke.printStackTrace();}} } 发布者订阅者模型 发布者将消息发布到JMS提供程序中的指定主题并且订阅该主题的所有订阅者都将收到该消息。 请注意只有活动的订户才能收到该消息。 点对点模型示例 package com.eviac.blog.jms;import javax.jms.*; import javax.naming.*;import org.apache.log4j.BasicConfigurator;import java.io.BufferedReader; import java.io.InputStreamReader;public class DemoPublisherSubscriberModel implements javax.jms.MessageListener {private TopicSession pubSession;private TopicPublisher publisher;private TopicConnection connection;/* Establish JMS publisher and subscriber */public DemoPublisherSubscriberModel(String topicName, String username,String password) throws Exception {// Obtain a JNDI connectionInitialContext jndi new InitialContext();// Look up a JMS connection factoryTopicConnectionFactory conFactory (TopicConnectionFactory) jndi.lookup(topicConnectionFactry);// Create a JMS connectionconnection conFactory.createTopicConnection(username, password);// Create JMS session objects for publisher and subscriberpubSession connection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);TopicSession subSession connection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);// Look up a JMS topicTopic chatTopic (Topic) jndi.lookup(topicName);// Create a JMS publisher and subscriberpublisher pubSession.createPublisher(chatTopic);TopicSubscriber subscriber subSession.createSubscriber(chatTopic);// Set a JMS message listenersubscriber.setMessageListener(this);// Start the JMS connection; allows messages to be deliveredconnection.start();// Create and send message using topic publisherTextMessage message pubSession.createTextMessage();message.setText(username : Howdy Friends!);publisher.publish(message);}/** A client can register a message listener with a consumer. A message* listener is similar to an event listener. Whenever a message arrives at* the destination, the JMS provider delivers the message by calling the* listeners onMessage method, which acts on the contents of the message.*/public void onMessage(Message message) {try {TextMessage textMessage (TextMessage) message;String text textMessage.getText();System.out.println(text);} catch (JMSException jmse) {jmse.printStackTrace();}}public static void main(String[] args) {BasicConfigurator.configure();try {if (args.length ! 3)System.out.println(Please Provide the topic name,username,password!);DemoPublisherSubscriberModel demo new DemoPublisherSubscriberModel(args[0], args[1], args[2]);BufferedReader commandLine new java.io.BufferedReader(new InputStreamReader(System.in));// closes the connection and exit the system when exit enters in// the command linewhile (true) {String s commandLine.readLine();if (s.equalsIgnoreCase(exit)) {demo.connection.close();System.exit(0);}}} catch (Exception e) {e.printStackTrace();}} } 参考 和ActiveMQ JMS从我们JCG伙伴 Pavithra Siriwardena在EVIAC博客。 翻译自: https://www.javacodegeeks.com/2012/07/jms-with-activemq.html
http://www.pierceye.com/news/446374/

相关文章:

  • 做网站设计怎么样网站建设先进技术
  • 廊坊cms建站系统wd wordpress
  • vue做网站的好处是什么顺企网下载
  • 在线建站模板下载网站的软件
  • 阿里云网站全部清空怎么做重庆市渝快办官网
  • 关于网站优化的文章室内设计公司排名都有哪些
  • 英文外贸网站建设中国建筑出版在线官网app
  • 浙江网站建设服务公司shopex网站搬家
  • 网站服务器无法访问百姓装潢上海门店具体地址
  • 怎么做网站推广怎么样网页截图快捷键是哪个
  • 常州网站制作费用如何搭建网站的支付接口
  • 网站会员体系网站后台都有哪些
  • 宜昌网站建设制作公司网站301在哪做
  • 备案网站分布地点wordpress如何去掉amp:
  • 做一个小说阅读网站怎么做网站 没有备案 访问不了
  • 乐山乐人网站建设公司网站域名查主机名
  • 自适应网站的代表腰肌劳损的自我治疗和恢复的方法有什么?
  • 玉环城乡建设规划局网站企业网站源码带后台
  • 网站热点关键词免费可商用素材网站
  • 网站站内优化案例自己做的网页怎么上传网站吗
  • 深圳制作网站有用吗如何做网站优化
  • 皖住房建设厅网站the 7 wordpress
  • 怎么自己学着做网站写网站代码
  • 自己电脑上做的网站 怎么让别人看怎么做网站在谷歌
  • 同一ip 网站 权重怎样做才能发布你的网站
  • 上海利恩建设集团有限公司网站社交网站先做pc站可以吗
  • 用网站做淘宝客新媒体销售好做吗
  • 手机模板的网站哪个好wordpress关闭google字体
  • 医疗行业网站怎么做网站反链和外链的区别
  • html网站开发事例教程一起做网店官网下载