环境:腾讯云centos7

注意:activemq安装插件,可能会报错。本人是主机名的问题,所以修改了主机名。

vim /etc/hosts

vim /etc/hostname

修改这两个文件,并重启主机,然后再运行activemq,没有问题了。

1、下载安装包

https://activemq.apache.org/components/classic/download/

2、解压安装包

tar -xzvf apache-activemq-5.15.9-bin.tar.gz

3、安装

mkdir /usr/java/

mv apache-activemq-5.15.9 /usr/java/activemq5.15

cd /usr/java/activemq5.15

4、运行mq

activemq    start
stop
status

5、验证是否启动成功

ss -tnalp 查看端口,如果有61616,则运行成功。

6、进入管理界面查看

http://ip:8161   初始密码:admin/admin

7、设置管理界面密码

    a) 在 mq安装目录/conf/jetty.xml中,添加权限控制。
<bean id="securityConstraint" class="org.eclipse.jetty.util.security.Constraint">
<property name="name" value="BASIC" />
<property name="roles" value="admin" />
<property name="authenticate" value="<span style="color:#ff0000;">true</span>" />
</bean> b)在 mq安装目录/conf/jetty-realm.properties中,添加用户
admin:password,admin

完毕!

 #########springboot实践##########

1、pom.xml添加依赖

  <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>

2、yml文件添加服务ip

#默认使用配置  #activemq
spring:
activemq:
broker-url: tcp://132.232.44.82:61616

3、ActiveProducer.java

package com.cn.commodity.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map; @RestController
public class ActiveProducer {
//注入jsmtemplate
@Autowired
private JmsMessagingTemplate jmsMessagingTemplate; @RequestMapping("/sendMsg")
public String sendMsg(String msg) {
jmsMessagingTemplate.convertAndSend("my_msg", msg);
System.out.println("msg发送成功:"+msg);
return "正发送邮件以及短信验证码,请注意查收";
} @RequestMapping("/sendMap")
public String sendMap() {
Map map = new HashMap();
map.put("mobile", "13888888888");
map.put("content", "王总喜提兰博基尼");
jmsMessagingTemplate.convertAndSend("my_map", map);
System.out.println("map发送成功: "+map);
return "map发送成功";
}
}

4、ActiveConsumer.java

package com.cn.commodity.controller;

import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
import java.util.Map; @Component
public class ActiveConsumer { @JmsListener(destination = "my_msg")
public void readMsg(String text) {
if(text!=null){
System.out.println("接收到消息:" + text);
}
} @JmsListener(destination = "my_map")
public void readMap(Map map) {
System.out.println(map);
}
}

启动测试 ,完毕!

springboot之activemq安装与实践的更多相关文章

  1. springboot之rabbitmq安装与实践

    环境:腾讯云centos7 注意:rabbitmq安装插件,可能会报错.本人是主机名的问题,所以修改了主机名. vim /etc/hosts vim /etc/hostname 修改这两个文件,并重启 ...

  2. springboot之kafka安装与实践

    环境:腾讯云centos7 1.下载 http://mirror.bit.edu.cn/apache/kafka/2.3.0/kafka_2.11-2.3.0.tgz 2.解压 tar -xvf ka ...

  3. activemq安装运行及其在springboot中的queue和topic使用

    安装activemq 运行 springboot使用 依赖 配置 Producer Consumer ComsumerTopic 使用 安装activemq http://activemq.apach ...

  4. SpringBoot JMS(ActiveMQ) 使用实践

    ActiveMQ 1. 下载windows办的activeMQ后,在以下目录可以启动: 2. 启动后会有以下提示 3. 所以我们可以通过http://localhost:8161访问管理页面,通过tc ...

  5. springboot与ActiveMQ整合

    前言 很多项目, 都不是一个系统就做完了. 而是好多个系统, 相互协作来完成功能. 那, 系统与系统之间, 不可能完全独立吧? 如: 在学校所用的管理系统中, 有学生系统, 资产系统, 宿舍系统等等. ...

  6. springboot整合activeMq 跳坑

    安装 activeMq 安装请看我的另一篇https://www.cnblogs.com/milicool/p/8420926.html 版本 springboot 2.0.5.RELEASE 项目结 ...

  7. springboot整合ActiveMQ 2(主备模式,负载均衡)

    基本使用,https://www.tapme.top/blog/detail/2018-09-05-10-38 主备模式,https://www.tapme.top/blog/detail/2018- ...

  8. SpringBoot整合ActiveMQ,看这篇就够了

    ActiveMQ是Apache提供的一个开源的消息系统,完全采用Java来实现,因此它能很好地支持JMS(Java Message Service,即Java消息服务)规范:本文将详细介绍下Activ ...

  9. SpringBoot之ActiveMQ实现延迟消息

    一.安装activeMQ ​ 安装步骤参照网上教程,本文不做介绍 二.修改activeMQ配置文件 ​ broker新增配置信息 schedulerSupport="true" & ...

随机推荐

  1. flask 反向解析示例

    1 静态网页 和动态网页 1 静态网页:无法与服务器做动态交互的网页 2 动态网页:允许与服务器做动态加护的 2 WEB 与 服务器 1 WEB :网页(HTML,css,JS) 3 服务器的作用: ...

  2. C#的预处理指令

  3. c# 运算符和表达式

  4. [daily]使用iptables配置NAT的命令速查

    时常,快速的配置一个临时的NAT环境是很常用需求. 但是,每次我都要读iptables的手册,才能配出来.所以,备忘一个速查. DNAT: iptables -t nat -A PREROUTING ...

  5. Django:总结setting中的配置

    一.Django setting配置说明 二.setting配置一览 一.Django setting配置说明 1.基础 DJANGO_SETTING_MODULE环境变量:让settings模块被包 ...

  6. keepalived+lvs+usp安装实施文档

    操作系统平台:RedHat6.4  x86_64 软件:LVS+keepalived LVS+Keepalived 介绍 LVS LVS是Linux Virtual Server的简写,意即Linux ...

  7. (17)for循环

    # 把容器里数据拿出来的这个过程 可以叫遍历 迭代 循环 listvar = [1, 2, 3, 4, 5] print(len(listvar)) # 算出列表里面所有元素的个数,len是计算长度 ...

  8. C#单元测试小例子

    步骤简略,特别处进行说明. 以VS2015为例. 1.创建一个解决方案方案,如添加一个ConsoleApplication1的解决方案. 2.在解决方案的默认项目中,添加一个Calc类 3.将Calc ...

  9. Java数组直接选择排序、sort()排序

    /** * 1.数组sort()排序 * 2.直接选择排序(两重for循环排序) */ import java.lang.*; import java.lang.reflect.Array; impo ...

  10. windows版idea 2018.3.5版 永久激活教程

    1.下载idea并安装:https://download.jetbrains.com/idea/ideaIU-2018.3.5.exe?_ga=2.179947812.1869744014.15658 ...