其他相关:
http://wangxinchun.iteye.com/blog/2145998
http://wangxinchun.iteye.com/blog/2145958
对于mq队列中的消息,有时候需要做监控或者问题跟踪要看看mq的数据,又要保证看后数据不会删除(比如:p2p 一旦consumer.receive 后mq不会发送其他consumer),mq提供了查看消息的功能。
最关键的代码为:
Queue destination = session.createQueue("test-queue");
QueueBrowser browser = session.createBrowser(destination);
Enumeration<?> enumeration = browser.getEnumeration();
案例如下:
public class Browser {
private static final String BROKER_URL = "tcp://localhost:61616";
private static final Boolean NON_TRANSACTED = false;
private static final long DELAY = 100;
public static void main(String[] args) {
String url = BROKER_URL;
if (args.length > 0) {
url = args[0].trim();
}
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("admin", "password", url);
Connection connection = null;
try {
connection = connectionFactory.createConnection();
connection.start();
Session session = connection.createSession(NON_TRANSACTED, Session.AUTO_ACKNOWLEDGE);
Queue destination = session.createQueue("test-queue");
QueueBrowser browser = session.createBrowser(destination);
Enumeration<?> enumeration = browser.getEnumeration();
while (enumeration.hasMoreElements()) {
TextMessage message = (TextMessage) enumeration.nextElement();
System.out.println("Browsing: " + message.getText());
TimeUnit.MILLISECONDS.sleep(DELAY);
}
session.close();
} catch (Exception e) {
System.out.println("Caught exception!");
}
finally {
if (connection != null) {
try {
connection.close();
} catch (JMSException e) {
System.out.println("Could not close an open connection...");
}
}
}
}
}
分享到:
相关推荐
activemq-all-5.8.0.jar 下载 activemq-all-5.8.0.jar 下载 activemq-all-5.8.0.jar 下载 activemq-all-5.8.0.jar 下载 activemq-all-5.8.0.jar 下载
activemq-pool-5.8.0-sources.jar
赠送jar包:activemq-core-5.7.0.jar; 赠送原API文档:activemq-core-5.7.0-javadoc.jar; 赠送源代码:activemq-core-5.7.0-sources.jar; 包含翻译后的API文档:activemq-core-5.7.0-javadoc-API文档-中文...
apache-activemq-5.16.0.zip
赠送jar包:activemq-protobuf-1.1.jar; 赠送原API文档:activemq-protobuf-1.1-javadoc.jar; 赠送源代码:activemq-protobuf-1.1-sources.jar; 包含翻译后的API文档:activemq-protobuf-1.1-javadoc-API文档-...
apache-activemq-5.9.0-bin.zip
apache-activemq-5.8.0-bin.zip
apache-activemq-5.15.15二进制包,安装包,apache-activemq-5.15.15-bin.tar.gz
解压缩apache-activemq-5.5.1-bin.zip,然后双击...包含了apache-activemq-5.5.1-bin.zip以及ActiveMQ一个helloworld的demo启动ActiveMQ以后,登陆:http://localhost:8161/admin/,创建一个Queue,命名为FirstQueue。
activemq-web-console的默认使用方式是通过在activemq.xml中导入jetty.xml配置一个jetty server来实现的。其实activemq-web-console完全可以和activemq-broker分开来部署。 activemq-web-console包含3个apps, 1.一...
activemq-cpp-library-3.9.5编译的C++库文件,支持vs2015,vs2017,包括了依赖的库文件和头文件,可以在项目中直接使用。
activemq-all-5.2.0.JAR包,欢迎下载。编写java中间件的时候会用到。这是activemq实现的jms中间件。希望能帮助到你。
tar -zxvf apache-activemq-5.15.12-bin.tar.gz 2.进入bin目录 cd /apache-activemq-5.15.12/bin 3.运行,没有配置环境变量只能在bin目录下使用命令 ./activemq 4.配置环境变量,配置完环境变量之后...
activemq-all.5.14jar包,亲测可用!!
activemq-protobuf-1.1.jar;activemq-protobuf-1.1.jar
apache-activemq-5.15.9-bin.zip apache-activemq-5.15.9-bin.zip apache-activemq-5.15.9-bin.zip
apache-activemq-5.15.3-bin apache-activemq-5.15.3-bin
标签:activemq-kahadb-store-5.9.1.jar,activemq,kahadb,store,5.9.1,jar包下载,依赖包
自己编译的activemq-cpp的2.X的最后版本,在windows + vs2010下测试通过。压缩包中包含了include\lib\dll文件。 由于尝试了N个3.X的版本都不同过,于是退到2.X版本,通过了,另外在vs2005下编译出来的也没有问题。...
activemq-cpp-library-3.9.5-src.zip