RocketMQ架构和角色

2019-02-07  本文已影响73人  黄靠谱

参考

官方角色的解释
http://rocketmq.apache.org/docs/rmq-arc/

RocketMQ架构解析
https://www.jianshu.com/p/015a16347640

概述

image

NameServer Cluster

        DefaultMQProducer producer = new DefaultMQProducer("please_rename_unique_group_name");
        producer.setNamesrvAddr("localhost:9876");
        producer.start();

        DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("please_rename_unique_group_name");
        consumer.setNamesrvAddr("localhost:9876");
        consumer.subscribe("TopicTest", "*");
        consumer.registerMessageListener(new MessageListenerConcurrently() { });

作用

NameServer集群的配置:

namesrvAddr = rocketmq-server1:9876;rocketmq-server2:9876

Broker Cluster

支持Consumer获取消息的两种模式:Push and Pull model

核心作用:消息的存储、分发、查询、高可用保证

  1. 存储和查询:Store Service, provides simple APIs to store or query message in physical disk.
  2. 消息索引查询:Index Service, builds index for messages by specified key and provides quick message query.
  3. 消息高可用:provides data sync feature between master broker and slave broker.
  4. 消息容错性:contains fault tolerance mechanism (2 copies or 3 copies)
  5. 客户端管理:manages the clients (Producer/Consumer) and maintains topic subscription of consumer.
  6. 统计和短信报警功能:Brokers provide disaster recovery, rich metrics statistics, and alert mechanisms, all of which are lacking in traditional messaging systems
  7. 可扩展性强:可以通过添加queueNum、新增Broker来提高集群的性能(因为解耦了,Client直接和nameServer交互,新broker在nameServer注册成功就可以加入到工作中)

Broker集群管理

https://www.cnblogs.com/xuwc/p/9043764.html

RocketMQ的Broker集群和solrCloud类似,有分片的功能:

  1. RocketMQ集群方式:单Master模式、多Master模式、多Master多Slave模式
  2. 单个Master和其Slave之间数据同步:(同步复制、异步复制):SYNC_MASTER、ASYNC_MASTE,异步复制的话,如果Master挂了,但是新消息未复制到Slave会导致消息丢失
  3. Broker的数据持久化方式:ASYNC_FLUSH、SYNC_FLUSH,一种是CommitLog持久化成功就返回消息存储成功,一种是到了内存就返回成功,异步的方式进行持久化
  4. Master对所有的Producer可见,Salve对所有的Consumer可见。
上一篇 下一篇

猜你喜欢

热点阅读