activemq

ActiveMQ集群方案

烈酒焚心 提交于 2019-12-03 16:34:08
ActiveMQ集群方案 本人最近使用VM搭建ActiveMQ集群成功了,写篇文章记录下。集群方案介绍。 MasterSlave模式 至少需要3个节点,利用 ZooKeeper 从众多节点中选举一个Master节点,其他为Slave节点。只有Master节点对外提供服务,使用LevelDB存储消息,当主节点宕机后,其他节点会选举出一个新的节点成为Master节点,继续对外提供服务。 优点:实现高可用,排除单节点故障导致的服务中断。 缺点:无法实现负载均衡,各个节点的消息无法同步。 BrokerCluster模式 不同节点的Broker之间通过 networkConnectors (网络连接器)方式同步消息,使得不同节点的消费者可以互相消费消息。 网络连接器:主要用于配置ActiveMQ服务器与服务器之间的网络通信方式,用于同步消息。分为静态和动态。 静态连接器:指定iP地址 < networkConnectors > < networkConnector uri = " static:(tcp://xxx,tcp://xxx) " /> </ networkConnectors > 动态连接器:广播 < networkConnectors > < networkConnector uri = " multicast://xxx " /> </ networkConnectors >

初识ActiveMQ消息中间件

孤者浪人 提交于 2019-12-03 15:50:55
ActiveMQ官方网站: https://activemq.apache.org/ 关于ActiveMQ消息传递的方式详见: https://segmentfault.com/a/1190000014958916 https://www.cnblogs.com/cyfonly/p/6380860.html 本篇博客旨在解决的问题: 1.如何在普通Java环境中使用ActiveMQ 2.ActiveMQ如何与Spring的整合(XML配置) 3.在SpringBoot中如何使用ActiveMQ 环境: 1. windows 10 64bit 2. apache-activemq-5.14.4 3. jdk 1.8 4. maven 3.3 前置条件: 1.安装启动ActiveMQ: 在官方网站( https://activemq.apache.org/components/classic/download/ )上下载ActiveMQ 解压后,进入到目录bin中,根据自己操作系统的位数进入到win64或者win32目录下,然后点击activemq.bat启动ActiveMQ。 启动后在浏览器输入 http://localhost:8161/ ,看到以下画面表示启动成功: 点击“ Manage ActiveMQ broker ”进入到ActiveMQ的后台管理界面

How to configure the ActiveMQ 5.10.0 HawtIO interface?

核能气质少年 提交于 2019-12-03 15:08:19
I'm using ActiveMQ 5.9.0 that has a amazing HawtIO interface. So when 5.10.0 has come, I migrated my system too. Now I see that the HawtIO interface doesn't exist inside it... It just disappeared from webapps folder from 5.9.0 to 5.10.0, so I tried the tutorial ActiveMQ and HawtIO but it doesn't work... How to configure the interface? Alternatively, you can use HawtIO as a standalone web-app, that connects to ActiveMQ through Jolokia (pre 5.9 way of doing it). Download the HawtIO standalone jar here: http://hawt.io/getstarted/index.html Run the jar on the ActiveMQ-server: java -jar hawtio-app

Writing tests to verify received msg in jms listener (Spring-Boot)

人走茶凉 提交于 2019-12-03 15:07:03
I want to write test for something like below; There is a listener called state-info-1 in src/main . It does some changes to any message it gets and publishes the new message on activemq topic state-info-2 . I will build a dummy message and publish on to activemq topic state-info-1 . Finally verify that, the received message on topic state-info-2 is like i expected. My Listeners are like; @JmsListener(destination = "state-info-1", containerFactory = "connFactory") public void receiveMessage(Message payload) { // Do Stuff and Publish to state-info-2 } Is it possible i can write test for this?

为什么现在Java面试都要求掌握分布式知识!

懵懂的女人 提交于 2019-12-03 15:00:09
新的一年又开始了,各大招聘咨询机构都会对过去一年市场上的人才供需进行盘点。 根据高端招聘平台 100 offer 发布的 Java 人才盘点报告, 在过去的 2018 年, Java 仍然是最流行、招聘供需量最大的技术语言。 在此基础上,互联网行业针对 Java 开发的招聘需求,也是近年技术类岗位供需量最大,且变化最稳定的。企业对 Java 工程师发放的面邀数占比也远高于其他岗位,在 100 offer 平台上, Java 工程师的需求占总需求的近 60% ,可以说,在当前各大公司 “ 裁员 ” 的背景下, Java 工程师,尤其是资深 Java 工程师依旧是硬通货。 什么样的工程师才能被称为资深,又如何成为资深 Java 工程师呢? 从工作时间来看,资深工程师一般具备 3-5 年工作经验,企业对有 3-5 年经验的 Java 工程师,都会要求算法基础和编程能力扎实,有分布式、高并发经验优先,可独立负责一个模块的开发。在技术上一专多能,不仅限于写好 Java ,还要触类旁通,对公司业务所需的新技术能快速学习运用,以一个资深 Java 开发招聘为例: 从上面的招聘信息可以看到几个信息: 1 、 即使在这个 “ 裁员 ” 寒冬里,企业也是愿意为有能力的资深 Java 工程师付费的。 一个资深程序员达到 50w+ 的待遇是没问题的。在 IT 届也流传着一个观点: 1

Retrying messages at some point in the future (ActiveMQ)

六眼飞鱼酱① 提交于 2019-12-03 13:11:52
问题 I'm working on a system in ActiveMQ where I would really prefer not to lose messages. My problem is that retrying messages is causing my consumers to block (instead of working on messages they could handle). I'd like to give failed messages several days to retry (for example, one of my potential destinations is another server I'll access via SFTP, which could be down), but I don't want a consumer blocking for several days -- I want it to keep working on the other messages. Is there a way to

How do I make Spring JMSListener burst to max concurrent threads?

删除回忆录丶 提交于 2019-12-03 12:24:08
I have a Spring JMS Application that is using ActiveMQ version 5.10. I am performing a simple test to concurrency. I am using Spring Boot, current version and annotations to configure JMSListener and message producers. The message producer just throws messsages on a queue as fast as it can. The message listener is pulling messages off the queue, but sleeping for 1 second after getting the message -- simulating some work that the message listener would need to do after getting a message. I have the JMSListener set to 100-1000 concurrent threads. If I start the message producer and consumer at

How to send ERROR message to STOMP clients with Spring WebSocket?

泪湿孤枕 提交于 2019-12-03 11:56:06
问题 I am using Spring's STOMP over WebSocket implementation with a full-featured ActiveMQ broker. When users SUBSCRIBE to a topic, there is some permissions logic that they must pass through before being successfully subscribed. I am using a ChannelInterceptor to apply the permissions logic, as configured below: WebSocketConfig.java: @EnableWebSocketMessageBroker public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer { @Override public void registerStompEndpoints

RESTful v/s MQ. Differences and other key features apart from Guaranteed Delivery

爷,独闯天下 提交于 2019-12-03 10:58:19
问题 Ok..So I have started studying about MQ and its purpose/usecase etc... My existing application (Web made using JSP etc..) uses RestFUL interface to communicate with a remote server and to post/receive data from the server. We often have to deal with the connectivity of the remote server.The synchronization problem is always there.. Message sent from our end.But Remote server went down. Or vice versa. I came across the MQ thing and found it to be reliable when delivering and receiving messages

Kafka、RabbitMQ、RocketMQ等消息中间件的介绍和对比(转)

二次信任 提交于 2019-12-03 10:55:51
前言 在分布式系统中,我们广泛运用消息中间件进行系统间的数据交换,便于异步解耦。现在开源的消息中间件有很多,前段时间产品 RocketMQ (MetaQ的内核) 也顺利开源,得到大家的关注。 概念 MQ简介 MQ,Message queue,消息队列,就是指保存消息的一个容器。具体的定义这里就不类似于数据库、缓存等,用来保存数据的。当然,与数据库、缓存等产品比较,也有自己一些特点,具体的特点后文会做详细的介绍。 现在常用的MQ组件有ActiveMQ、RabbitMQ、RocketMQ、ZeroMQ、MetaMQ,当然近年来火热的kafka,从某些场景来说,也是MQ,当然kafka的功能更加强大,虽然不同的MQ都有自己的特点和优势,但是,不管是哪种MQ,都有MQ本身自带的一些特点,下面,介绍MQ的特点。 MQ特点 1、先进先出 不能先进先出,都不能说是队列了。消息队列的顺序在入队的时候就基本已经确定了,一般是不需人工干预的。而且,最重要的是,数据是只有一条数据在使用中。 这也是MQ在诸多场景被使用的原因。 2、发布订阅 发布订阅是一种很高效的处理方式,如果不发生阻塞,基本可以当做是同步操作。这种处理方式能非常有效的提升服务器利用率,这样的应用场景非常广泛。 3、持久化 持久化确保MQ的使用不只是一个部分场景的辅助工具,而是让MQ能像数据库一样存储核心的数据。 4、分布式 在现在大流量