源码地址:  https://gitee.com/kevin9401/microservice.git

一、安装 ActiveMQ:

1. 下载 ActiveMQ

wget  https://archive.apache.org/dist/activemq/5.14.0/apache-activemq-5.14.0-bin.tar.gz

2. 解压 并且重命名 为 activemq

tar -zxvf apache-activemq-5.14.0-bin.tar.gz && mv apache-activemq-5.14.0 activemq

3.  配置环境变量(不做也行,暂时没发现用处)

vim /etc/profile

添加

export ACTIVEMQ_HOME=/usr/local/softwares/activemq

export PATH=:$JAVA_HOME/bin:$ACTIVEMQ_HOME/bin:$PATH

使配置生效:

source /etc/profile

4.  进入目录,启动 activemq

cd /usr/local/softwares/activemq/bin/linux-x86-64

执行

./activemq start

5.  访问

ip:8161

点击 Manage ActiveMQ broker

6.  如果要输入用户名、密码,默认的是 admin/admin

【备注】 如果访问不了,应该是被防火墙阻挡了,可以选择 关闭防火墙,或者在放行列表中 添加 8161(web管理页面端口)、61616(activemq服务监控端口) 两个端口

如果防火墙是开启的:

打开linux防火墙端口

/sbin/iptables -I INPUT -p tcp --dport 8161 -j ACCEPT&&/etc/init.d/iptables save&&service iptables restart&&/etc/init.d/iptables status

/sbin/iptables -I INPUT -p tcp --dport 61616 -j ACCEPT&&/etc/init.d/iptables save&&service iptables restart&&/etc/init.d/iptables status

二、spring boot 整合 activemq

1. 引入依赖

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

2. 创建消息队列对象

@Configuration
public class QueueConfig { /**
* 创建 名称为 active.queue 的消息队列对象
*
* @return
*/
@Bean
public Queue queue() {
return new ActiveMQQueue("active.queue1");
}
}

3. 创建消息生产者

@RestController
public class QueueController { @Autowired
private JmsMessagingTemplate messagingTemplate; @Autowired
private Queue queue; /**
* 消息生产者
*/
@RequestMapping(value = "/send")
public void send() {
messagingTemplate.convertAndSend(queue, "hello world");
}
}

4. 在 application.yml 中配置连接

spring:
activemq:
broker-url: tcp://ip:61616

5.  启动项目,调用发送消息接口

6. 查看消息队列

参考:https://www.cnblogs.com/shamo89/p/7645651.html

------------恢复内容开始------------

源码地址:

一、安装 ActiveMQ:

1. 下载 ActiveMQ

wget  https://archive.apache.org/dist/activemq/5.14.0/apache-activemq-5.14.0-bin.tar.gz

2. 解压 并且重命名 为 activemq

tar -zxvf apache-activemq-5.14.0-bin.tar.gz && mv apache-activemq-5.14.0 activemq

3.  配置环境变量(不做也行,暂时没发现用处)

vim /etc/profile

添加

export ACTIVEMQ_HOME=/usr/local/softwares/activemq

export PATH=:$JAVA_HOME/bin:$ACTIVEMQ_HOME/bin:$PATH

使配置生效:

source /etc/profile

4.  进入目录,启动 activemq

cd /usr/local/softwares/activemq/bin/linux-x86-64

执行

./activemq start

5.  访问

ip:8161

点击 Manage ActiveMQ broker

6.  如果要输入用户名、密码,默认的是 admin/admin

【备注】 如果访问不了,应该是被防火墙阻挡了,可以选择 关闭防火墙,或者在放行列表中 添加 8161(web管理页面端口)、61616(activemq服务监控端口) 两个端口

如果防火墙是开启的:

打开linux防火墙端口

/sbin/iptables -I INPUT -p tcp --dport 8161 -j ACCEPT&&/etc/init.d/iptables save&&service iptables restart&&/etc/init.d/iptables status

/sbin/iptables -I INPUT -p tcp --dport 61616 -j ACCEPT&&/etc/init.d/iptables save&&service iptables restart&&/etc/init.d/iptables status

二、spring boot 整合 activemq

1. 引入依赖

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

2. 创建消息队列对象

@Configuration
public class QueueConfig { /**
* 创建 名称为 active.queue 的消息队列对象
*
* @return
*/
@Bean
public Queue queue() {
return new ActiveMQQueue("active.queue1");
}
}

3. 创建消息生产者

@RestController
public class QueueController { @Autowired
private JmsMessagingTemplate messagingTemplate; @Autowired
private Queue queue; /**
* 消息生产者
*/
@RequestMapping(value = "/send")
public void send() {
messagingTemplate.convertAndSend(queue, "hello world");
}
}

4. 在 application.yml 中配置连接

spring:
activemq:
broker-url: tcp://ip:61616

5.  启动项目,调用发送消息接口

6. 查看消息队列

参考:https://www.cnblogs.com/shamo89/p/7645651.html

------------恢复内容结束------------

liunx 安装ActiveMQ 及 spring boot 初步整合 activemq的更多相关文章

  1. elasticsearch 的安装配置与spring boot的整合应用

    linux上的elasticsearch安装 一.下载elasticsearch 直接进入elasticsearch的官网,下载最新的安装包:https://www.elastic.co/downlo ...

  2. Spring Boot 监听 Activemq 中的特定 topic ,并将数据通过 RabbitMq 发布出去

    1.Spring Boot 和 ActiveMQ .RabbitMQ 简介 最近因为公司的项目需要用到 Spring Boot , 所以自学了一下, 发现它与 Spring 相比,最大的优点就是减少了 ...

  3. 【ActiveMQ】2.spring Boot下使用ActiveMQ

    在spring boot下使用ActiveMQ,需要一下几个条件 1.安装并启动了ActiveMQ,参考:http://www.cnblogs.com/sxdcgaq8080/p/7919489.ht ...

  4. Spring Boot Security 整合 JWT 实现 无状态的分布式API接口

    简介 JSON Web Token(缩写 JWT)是目前最流行的跨域认证解决方案.JSON Web Token 入门教程 - 阮一峰,这篇文章可以帮你了解JWT的概念.本文重点讲解Spring Boo ...

  5. Spring boot Mybatis 整合(完整版)

    个人开源项目 springboot+mybatis+thymeleaf+docker构建的个人站点开源项目(集成了个人主页.个人作品.个人博客) 朋友自制的springboot接口文档组件swagge ...

  6. Spring boot Mybatis 整合

    PS: 参考博客 PS: spring boot配置mybatis和事务管理 PS: Spring boot Mybatis 整合(完整版)   这篇博客里用到了怎样 生成 mybatis 插件来写程 ...

  7. spring boot 学习(二)spring boot 框架整合 thymeleaf

    spring boot 框架整合 thymeleaf spring boot 的官方文档中建议开发者使用模板引擎,避免使用 JSP.因为若一定要使用 JSP 将无法使用. 注意:本文主要参考学习了大神 ...

  8. Spring Boot 应用系列 5 -- Spring Boot 2 整合logback

    上一篇我们梳理了Spring Boot 2 整合log4j2的配置过程,其中讲到了Spring Boot 2原装适配logback,并且在非异步环境下logback和log4j2的性能差别不大,所以对 ...

  9. Spring boot Mybatis 整合(注解版)

    之前写过一篇关于springboot 与 mybatis整合的博文,使用了一段时间spring-data-jpa,发现那种方式真的是太爽了,mybatis的xml的映射配置总觉得有点麻烦.接口定义和映 ...

随机推荐

  1. git 回滚版本

    方法一.(回滚到原来的版本) 1.在gitlab上找到要恢复的版本号,如: bbdca96 2.在客户端执行如下命令(执行前,先将本地代码切换到对应分支): git reset --hard bbdc ...

  2. grafan源码编译

    下载grafana源码:https://github.com/grafana/grafana 前端: 安装node.js,安装完自带npmnpm install -g yarnyarn install ...

  3. 2021 祥云杯 wp

    52 web ezyii https://pan.baidu.com/s/1j7IJm9xiea5FvBhPMkPNoQ 提取码GAME <?php include("closure/ ...

  4. HTTPS-自己生成数字证书

    一.获取证书的途径 自签名证书,适用于开发者测试HTTPS,最快速的途径就是生成自签名证书,非常方便. Let's Encrypt证书,可以使用免费CA机构签发的证书. 使用收费CA机构签发的证书,如 ...

  5. php 递推 递归

    思想:如何利用数学模式,来解决对应的需求问题,然后利用代码实现对应的数据模型(逻辑) 算法:使用代码实现对应的数学模型,从而解决对应的业务问题 递推算法是一种简单的算法,级通过已知条件,利用特定关系得 ...

  6. VC练习一

    1 #include<windows.h> 2 #include<stdio.h> 3 LRESULT CALLBACK WinSunProc(HWND hwnd,UINT u ...

  7. [cf1361E]James and the Chase

    称一个点是"好点",当且仅当其到其余所有点恰存在一条简单路径 结论1:$x$为好点当且仅当以$x$为根的dfs树包含所有点且非树边均为返祖边 若不包含所有点,那么$x$到不被包含的 ...

  8. [hdu7033]Typing Contest

    为了避免浮点运算,不妨将$f_{i}$​​​乘上$C=10^{2}$​​​,问题即求$\max_{S\subseteq [1,n]}\frac{\sum_{i\in S}(C^{2}-(\sum_{j ...

  9. UNCTF2020 web writeup

    1.Easy_ssrf 给了file_get_contents,直接读取flag即可 2.Easyunserialize 利用点在 构造uname反序列化逃逸即可 3.Babyeval 两个过滤,绕过 ...

  10. Sentry 监控 - Snuba 数据中台架构(编写和测试 Snuba 查询)

    系列 1 分钟快速使用 Docker 上手最新版 Sentry-CLI - 创建版本 快速使用 Docker 上手 Sentry-CLI - 30 秒上手 Source Maps Sentry For ...