ActivMq 搭建

JMS即Java Message Service(消息中间件),用于在两个应用程序之间,或分布式系统中发送消息,进行异步通信,以解除两个程序之间的耦合。

ActiveMQ 是 Apache 出品,最流行的、能力强劲的开源消息总线。ActiveMQ 是一个完全支持 JMS1.1 和 J2EE 1.4 规范的 JMS Provider 实现,可以很容易内嵌到使用Spring的系统里面去,所以我们选择它。
两种模式 点对点(point to point, queue)和发布/订阅(publish/subscribe,topic);

搭建activeMq

  1. 首先下载对应环境的mq版本

    下载地址

  2. 新建用户

    [root@gd_vtm ~]# adduser mq
    
  3. 输入密码

    [root@gd_vtm ~]# passwd mq
    
  4. 解压mq
    切换至mq用户下,上传压缩包,并解压 ,建立目录结构如下图

    [mq@gd_vtm ~]$ tar -xzvf apache-activemq-5.15.7
    

在这里插入图片描述

  1. 安装jdk
    上传jdk压缩文件至java目录

    tar -xzvf jdk-8u171-linux-x64.tar.gz
    

    修改配置文件

    vi .bash_profile
    

    在path后面添加jdk及activemq的参数
    在这里插入图片描述

    到目前为止已经安装完毕

  2. 进入启动目录(获取linux系统位数进入对应的目录32/64)

    cd  apache-activemq-5.15.7/bin/linux-x86-64
    
  3. 启动

    ./activemq start;
    

查看端口 启动成功如下图
在这里插入图片描述

进入控制台在 浏览器输入 ip:8161
在这里插入图片描述

  1. 问题
    如果启动有问题,我们需要查看下日志
    日志位置在/home/mq/apache-activemq-5.15.7/data目录下
  • 1 主机ip问题

    Illegal character in hostname at index 7:
    ws://gd_vtm:61614?maximumConnections=1000&wireFormat.maxFr

修改/home/mq/apache-activemq-5.15.7/conf/activmq.xml文件

 <transportConnectors>
        <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
        <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    </transportConnectors>

修改为

<transportConnectors>
            <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
            <transportConnector name="openwire" uri="tcp://127.0.0.1:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="amqp" uri="amqp://127.0.0.1:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="stomp" uri="stomp://127.0.0.1:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="mqtt" uri="mqtt://127.0.0.1:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="ws" uri="ws://127.0.0.1:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
        </transportConnectors>
  • 2 jdk问题

nsupported major.minor version 52.0

将jdk版本升级为1.8

例子 SpringBoot + ActiveMq

猜你喜欢

转载自blog.csdn.net/qq_31941773/article/details/83588459