springboot整合activemq,实现broker集群部署(cluster)

  1、为实现jms高并发操作,需要对activemq进行集群部署,broker cluster就是activemq自带的解决方案。这里以一台主机来进行演示:原有的activemq作为broker-a,再新建一个activemq服务作为broker-b

  2、对broker-b的tcp端口及管理端口进行修改

    (1)tcp端口:修改config目录下的activemq.xml ,端口号改为:61617,因为只用到tcp模式,其他方式注掉防止端口冲突

     <transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:61617?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>

    (2)管理端口:修改config目录下的jetty.xml,端口号改为:8162

   <bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start">
<!-- the default port number for the web console -->
<property name="host" value="0.0.0.0"/>
<property name="port" value="8162"/>
</bean>

  3、broker-a,broker-b相互添加通信,修改activemq.xml文件,broker-a中配置如下,broker-b同理

     <networkConnectors>
<networkConnector uri="static:(tcp://localhost:61617)" duplex="false"/>
</networkConnectors>

  4、配置好之后,在程序中application.properties修改配置,将原来的访问地址注掉,改为集群部署

#访问地址
#spring.activemq.broker-url=tcp://127.0.0.1:61616
#集群配置
spring.activemq.broker-url=failover:(tcp://localhost:61616,tcp://localhost:61617)

  5、在controller中增加测试方法,启动broker-a、broker-b,访问地址:http://localhost:8080/msg/testdis

  @GetMapping("testdis")
public String testdis() { Destination destination = new ActiveMQQueue("test.queue");
for(int i =1;i<10;i++) {
msgService.sendMessage(destination, "测试消息=====第"+i);
} return "测试集群部署";
}

  控制台输出如下,说明集群部署成功,activemq还支持master-slave模式,通过文件共享-文件锁的方式来实现集群拓展,这个我们只需要将activemq.xml中的kahaDB路径配置成相同的即可 

springboot 学习笔记(九)的更多相关文章

  1. SpringBoot学习笔记

    SpringBoot个人感觉比SpringMVC还要好用的一个框架,很多注解配置可以非常灵活的在代码中运用起来: springBoot学习笔记: .一.aop: 新建一个类HttpAspect,类上添 ...

  2. 多线程学习笔记九之ThreadLocal

    目录 多线程学习笔记九之ThreadLocal 简介 类结构 源码分析 ThreadLocalMap set(T value) get() remove() 为什么ThreadLocalMap的键是W ...

  3. Springboot学习笔记(六)-配置化注入

    前言 前面写过一个Springboot学习笔记(一)-线程池的简化及使用,发现有个缺陷,打个比方,我这个线程池写在一个公用服务中,各项参数都定死了,现在有两个服务要调用它,一个服务的线程数通常很多,而 ...

  4. MDX导航结构层次:《Microsoft SQL Server 2008 MDX Step by Step》学习笔记九

    <Microsoft SQL Server 2008 MDX Step by Step>学习笔记九:导航结构层次   SQL Server 2008中SQL应用系列及BI笔记系列--目录索 ...

  5. python3.4学习笔记(九) Python GUI桌面应用开发工具选择

    python3.4学习笔记(九) Python GUI桌面应用开发工具选择 Python GUI开发工具选择 - WEB开发者http://www.admin10000.com/document/96 ...

  6. Go语言学习笔记九: 指针

    Go语言学习笔记九: 指针 指针的概念是当时学C语言时了解的.Go语言的指针感觉与C语言的没啥不同. 指针定义与使用 指针变量是保存内存地址的变量.其他变量保存的是数值,而指针变量保存的是内存地址.这 ...

  7. SpringBoot学习笔记(14):使用SpringBootAdmin管理监控你的应用

    SpringBoot学习笔记(14):使用SpringBootAdmin管理监控你的应用 Spring Boot Admin是一个管理和监控Spring Boot应用程序的应用程序.本文参考文档: 官 ...

  8. SpringBoot学习笔记(3):静态资源处理

    SpringBoot学习笔记(3):静态资源处理 在web开发中,静态资源的访问是必不可少的,如:Html.图片.js.css 等资源的访问. Spring Boot 对静态资源访问提供了很好的支持, ...

  9. SpringBoot学习笔记(2):引入Spring Security

    SpringBoot学习笔记(2):用Spring Security来保护你的应用 快速开始 本指南将引导您完成使用受Spring Security保护的资源创建简单Web应用程序的过程. 参考资料: ...

  10. SpringBoot学习笔记(7):Druid使用心得

    SpringBoot学习笔记(7):Druid使用心得 快速开始 添加依赖 <dependency> <groupId>com.alibaba</groupId> ...

随机推荐

  1. Linux TCP通信例子

    TCP通信的C/S模型 ///server.c #include <sys/types.h> #include <sys/socket.h> #include <stdi ...

  2. Oracal主键 唯一报错

    ORA-00001: 违反唯一约束条件 --解决方法 2017年07月27日 12:04:11 阅读数:11853 1.错误 Caused by: java.sql.BatchUpdateExcept ...

  3. 八数码 Java实现

    参考http://blog.csdn.net/helloworld10086/article/details/41853389 package com.EightNumber.view; import ...

  4. 4. DVWA亲测暴力破解

    LOW等级 我们先用burpsuite抓包,因为burpsuite提供了暴力破解模块   我们先创建一个1.txt文件夹,把正确的账号密码写进去   我们输入 Username:1 Password: ...

  5. 微信小程序自学第二课:app及页面的生命周期、使用setData绑定数据

    一.App声明周期 1.App() app.js中的App() 函数用来注册一个小程序.接受一个 object 参数,其指定小程序的生命周期函数等. 示例代码: App({ onLaunch: fun ...

  6. C# 字符串转JSON

    一.简单小结 C# 中 String 转 JSON var items = JsonConvert.DeserializeObject<class>(stringJSON); 这里的 cl ...

  7. [WIP]php入門

    创建: 2019/06/19 安装  MAMP   变量与运算符  php标签  <?php ... ?> <?php ... ?> ● 在文件最后的 ?> 通常省略, ...

  8. mysql 索引总结

    一.MYSQL索引类型(共三种) 1).normal 正常 应用场景:普通的index 2).unique 唯一性的 应用场景:比如身份证的 3).full text 全文索引 应用场景:较长文字 二 ...

  9. 配置OpenCV报应用程序无法正常启动0xc000007b

    我的配置软件是OpenCV3.4.1和visual studio2017.参考这篇博客(https://blog.csdn.net/qq_41175905/article/details/805604 ...

  10. 中山纪念中学20170310洗衣服(贪心,优先队列升序【pair】)

    #include<bits/stdc++.h>using namespace std;typedef pair<long long,int>clot;priority_queu ...