资源简介
该资源为apollo搭建mqtt服务器,版本为apollo1.7.1,具体搭建方式及简单配置可参考本账号博客文章。
代码片段和文件信息
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License Version 2.0
* (the “License“); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing software
* distributed under the License is distributed on an “AS IS“ BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package example;
import org.apache.qpid.amqp_1_0.jms.impl.*;
import javax.jms.*;
class Listener {
public static void main(String []args) throws JMSException {
String user = env(“APOLLO_USER“ “admin“);
String password = env(“APOLLO_PASSWORD“ “password“);
String host = env(“APOLLO_HOST“ “localhost“);
int port = Integer.parseInt(env(“APOLLO_PORT“ “61613“));
String destination = arg(args 0 “topic://event“);
ConnectionFactoryImpl factory = new ConnectionFactoryImpl(host port user password);
Destination dest = null;
if( destination.startsWith(“topic://“) ) {
dest = new TopicImpl(destination);
} else {
dest = new QueueImpl(destination);
}
Connection connection = factory.createConnection(user password);
connection.start();
Session session = connection.createSession(false Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(dest);
long start = System.currentTimeMillis();
long count = 1;
System.out.println(“Waiting for messages...“);
while(true) {
Message msg = consumer.receive();
if( msg instanceof TextMessage ) {
String body = ((TextMessage) msg).getText();
if( “SHUTDOWN“.equals(body)) {
long diff = System.currentTimeMillis() - start;
System.out.println(String.format(“Received %d in %.2f seconds“ count (1.0*diff/1000.0)));
connection.close();
System.exit(1);
} else {
try {
if( count != msg.getIntProperty(“id“) ) {
System.out.println(“mismatch: “+count+“!=“+msg.getIntProperty(“id“));
}
} catch (NumberFormatException ignore) {
}
if( count == 1 ) {
start = System.currentTimeMillis();
} else if( count % 1000 == 0 ) {
System.o
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5476 2015-01-29 10:55 apache-apollo-1.7.1\bin\apollo
文件 2901 2018-08-30 16:18 apache-apollo-1.7.1\bin\apollo.cmd
文件 42511 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\blog\index.html
文件 49576 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\blog\index.rss
文件 3963 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\blog\releases\release-1-0-beta1.html
文件 6551 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\blog\releases\release-1-0-beta2.html
文件 5820 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\blog\releases\release-1-0-beta3.html
文件 5550 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\blog\releases\release-1-0-beta4.html
文件 5710 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\blog\releases\release-1-0-beta5.html
文件 5133 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\blog\releases\release-1-0-beta6.html
文件 6274 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\blog\releases\release-1.0.html
文件 3206 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\blog\releases\release-1.1.html
文件 3663 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\blog\releases\release-1.2.html
文件 3382 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\blog\releases\release-1.3.html
文件 2996 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\blog\releases\release-1.4.html
文件 4064 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\blog\releases\release-1.5.html
文件 3525 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\blog\releases\release-1.6.html
文件 4848 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\blog\releases\release-1.7.html
文件 4448 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\community\building.html
文件 5678 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\community\contributing.html
文件 3392 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\community\developers.html
文件 4816 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\community\faq.html
文件 5006 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\community\index.html
文件 3749 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\community\release-guide.html
文件 4138 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\community\site.html
文件 6417 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\community\source.html
文件 2781 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\community\support.html
文件 20977 2015-01-29 10:54 apache-apollo-1.7.1\docs\site\documentation\amqp-manual.html
文件 34898 2015-01-29 10:47 apache-apollo-1.7.1\docs\site\documentation\api\apollo-broker\index\index-a.html
文件 19389 2015-01-29 10:47 apache-apollo-1.7.1\docs\site\documentation\api\apollo-broker\index\index-b.html
............此处省略1400个文件信息
相关资源
- Apache Subversion1.10.3服务端SVN
- MQTT_3.1protocol_Specific中文版
- apache-maven-3.6.0
- apache-httpd2.5安装及配置(包含教程及
- hadoop技术内幕三件套
- 2012robocup3d 冠军南邮可执行代码
- Graph Algorithms:Practical Examples in Apach
- The Apache Ignite book PDF(正版购买的全网
- MQTTv3.1中文版
- mt7628 mqtt功能 放到packet下面就可以使
- MQTT-1.zip
- apache-tomcat-7.0.79.zip
- apache_2.2.14.rar
- 耶鲁博弈论笔记全 24 讲 v2.0Apollo Gab
- STM32F103C8T6与MQTT通信的源码
- Apache atlas使用说明文档.pdf转载分享请
- ESP8266使用MQTT协议连接阿里云
- ESP8266程序加上MQTT调试工具
- STM32(TCP转MQTT).rar
- DHT11温湿度传感器项目代码.rar
- apache-maven-3.2.3.zip
- apr-1.5.2.tar.gz+apr-util-1.5.2.tar.gz
- Practical Graph Analytics with Apache Giraph(
- 大数据元数据开源解决方案apache atl
- mqtt资料加源码stm32单片机+TCP
- Optimal Trajectory Generation for Dynamic Stre
- apache/httpd安全配置方法总结
- apache 2.4
- Linux CentOS离线环境下安装Apache所需要
- Apachehttpd-2.2.21-win32-x86-no_ssl.msi
评论
共有 条评论