• 大小: 67.01MB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2022-08-29
  • 语言: Java
  • 标签: activeMQ  

资源简介

分享-windows版最新的apache-activemq-5.16.0 。 使用activeMQ来完成jms的发送,必须要下载activeMQ,然后再本机安装,并且启动activeMQ的服务才行。在官网下载完成之后,运行bin目录下面的activemq.bat,将activeMQ成功启动。启动成功之后可以运行:http://localhost:8161/admin/index.jsp 查看一下

资源截图

代码片段和文件信息

/**
 * 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.jms.*;
import javax.jms.*;

class Listener {

    public static void main(String[] args) throws JMSException {

        final String TOPIC_PREFIX = “topic://“;

        String user = env(“ACTIVEMQ_USER“ “admin“);
        String password = env(“ACTIVEMQ_PASSWORD“ “password“);
        String host = env(“ACTIVEMQ_HOST“ “localhost“);
        int port = Integer.parseInt(env(“ACTIVEMQ_PORT“ “5672“));

        String connectionURI = “amqp://“ + host + “:“ + port;
        String destinationName = arg(args 0 “topic://event“);

        JmsConnectionFactory factory = new JmsConnectionFactory(connectionURI);

        Connection connection = factory.createConnection(user password);
        connection.start();
        Session session = connection.createSession(false Session.AUTO_ACKNOWLEDGE);

        Destination destination = null;
        if (destinationName.startsWith(TOPIC_PREFIX)) {
            destination = session.createTopic(destinationName.substring(TOPIC_PREFIX.length()));
        } else {
            destination = session.createQueue(destinationName);
        }

        MessageConsumer consumer = session.createConsumer(destination);
        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();
                    try {
                        Thread.sleep(10);
                    } catch (Exception e) {}
                    System.exit(1);
                } else {
                    try {
                        if (count != msg.getIntProperty(“id“)) {
                            System.out.println(“mismatch: “ + count + “!=“ + msg.getIntPrope

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\
     目录           0  2020-06-25 08:07  apache-activemq-5.16.0\conf\
     目录           0  2020-06-25 08:07  apache-activemq-5.16.0\data\
     目录           0  2020-06-25 08:07  apache-activemq-5.16.0\docs\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\amqp\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\amqp\java\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\amqp\java\src\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\amqp\java\src\main\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\amqp\java\src\main\java\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\amqp\java\src\main\java\example\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\amqp\python\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\conf\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\mqtt\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\mqtt\java\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\mqtt\java\src\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\mqtt\java\src\main\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\mqtt\java\src\main\java\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\mqtt\java\src\main\java\example\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\mqtt\websocket\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\mqtt\websocket\css\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\mqtt\websocket\img\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\mqtt\websocket\js\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\openwire\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\openwire\advanced-scenarios\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\openwire\advanced-scenarios\jms-example-composite-destinations\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\openwire\advanced-scenarios\jms-example-composite-destinations\src\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\openwire\advanced-scenarios\jms-example-composite-destinations\src\main\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\openwire\advanced-scenarios\jms-example-composite-destinations\src\main\java\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\openwire\advanced-scenarios\jms-example-composite-destinations\src\main\java\example\
     目录           0  2020-06-25 08:08  apache-activemq-5.16.0\examples\openwire\advanced-scenarios\jms-example-composite-destinations\src\main\java\example\composite\
............此处省略671个文件信息

评论

共有 条评论