不为有趣之事,何遣有涯之生
不失其所者久,死而不亡者寿

AMQ简明教程(12) AMQ集群

AMQ集群

Queue consumer clusters

ActiveMQ支持Consumer对消息高可靠性的负载平衡消费,如果一个Consumer死掉,该消息会转发到其它的Consumer消费的Queue上。
如果一个Consumer获得消息比其它Consumer快,那么他将获得更多的消息。
因此推荐ActiveMQ的Broker和Client使用failover://transport的方式来配置链接

Broker clusters

大部情况下是使用一系列的Broker和Client链接到一起。如果一个Broker死掉了,Client可以自动链接到其它Broker上。实现以上行为需要用failover协议作为Client。

如果启动了多个Broker,Client可以使用static discover或者 Dynamic discovery容易的从一个broker到另一个broker直接链接。

这样当一个broker上没有Consumer的话,那么它的消息不会被消费的,然而该broker会通过存储和转发的策略来把该消息发到其它broker上。

特别注意:ActiveMQ默认的两个broker,static链接后是单方向的,broker-A可以访问消费broker-B的消息,如果要支持双向通信,需要在netWorkConnector配置的时候,设置duplex=true 就可以了。

消息会较为平均的分配给2个集群,而不是每个消费者。即使某个消费者集群的消费者比其他集群中多,它获得的消息总数仍然差不多。不适合机器性能不均等的架构。

原因:networkConnector配置的可用属性conduitSubscriptions :默认true,标示是否把同一个broker的多个consumer当做一个来处理

负载均衡的时候一般设置为false, 设置为false后,会按照消费者个数来分配。

Master Slave

在5.9的版本里面,废除了Pure Master Slave的方式,目前支持:

1:Shared File System Master Slave:基于共享储存的Master-Slave:多个broker实例使用一个存储文件,谁拿到文件锁就是master,其他处于待启动状态,如果master挂掉了,某个抢到文件锁的slave变成master

2:JDBC Master Slave:基于JDBC的Master-Slave:使用同一个数据库,拿到LOCK表的写锁的broker成为master

3:Replicated LevelDB Store:基于ZooKeeper复制LevelDB存储的Master-Slave机制,这个是5.9新加的
具体的可以到官方察看: http://activemq.apache.org/masterslave.html

JDBC Master Slave的方式

利用数据库作为数据源,采用Master/Slave模式,其中在启动的时候Master首先获
得独有锁,其它Slaves Broker则等待获取独有锁。
推荐客户端使用Failover来链接Brokers。
具体如下图所示:

Master失败
如果Master失败,则它释放独有锁,其他Slaver则获取独有锁,其它Slaver立即获得独有锁后此时它将变成Master,并且启动所有的传输链接。同时,Client将停止链接之
前的Master和将会轮询链接到其他可以利用的Broker即新Master。如上中图所示

Master重启
任何时候去启动新的Broker,即作为新的Slave来加入集群,如上右图所示

JDBC Master Slave的配置

使用来配置消息的持久化,自动就会使用JDBC MasterSlave的方式。

未经允许不得转载:菡萏如佳人 » AMQ简明教程(12)
分享到: 更多 (0)

评论 30

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #1

    Marvelous, what a blog it is! This website provides valuable facts to us,
    keep it up.

    Сialis7个月前 (11-08)回复
  2. #2

    Please stop by the sites we follow, including this a single, because it represents our picks in the web.

    Google3个月前 (03-01)回复
  3. #3

    I know this web site gives quality depending content and other stuff, is there any other site which
    provides these information in quality?

    minecraft2个月前 (03-23)回复
  4. #4

    Everything is very open with a really clear
    explanation of the issues. It was truly informative.

    Your site is extremely helpful. Many thanks for sharing!

    minecraft2个月前 (03-28)回复
    • I'm glad it helped

      hzqiuxm2个月前 (03-29)回复
  5. #5

    If some one needs expert view about blogging and site-building after that i propose him/her to pay a quick visit
    this webpage, Keep up the nice job.

    tinyurl.com1个月前 (04-15)回复
  6. #6

    I have fun with, cause I discovered exactly
    what I used to be looking for. You have ended my 4
    day lengthy hunt! God Bless you man. Have a nice day. Bye

    minecraft1个月前 (04-15)回复
  7. #7

    Sweet blog! I found it while searching on Yahoo News. Do you have any tips on how to get
    listed in Yahoo News? I've been trying for a while but I never seem
    to get there! Many thanks

    minecraft1个月前 (04-18)回复
  8. #8

    What's up to every body, it's my first go to see of
    this website; this website contains amazing and really excellent information designed for visitors.

    minecraft1个月前 (04-19)回复
  9. #9

    I all the time emailed this web site post page to all my friends, for the reason that if like to read it next my links
    will too.

    http://tinyurl.com1个月前 (04-20)回复
    • thanks!

      hzqiuxm4周前 (04-26)回复
  10. #10

    We are a group of volunteers and starting a new scheme in our community.
    Your site offered us with valuable info to work on. You have performed a formidable activity and our entire group shall
    be thankful to you.

    minecraft1个月前 (04-21)回复
    • Thank you, and congratulations!

      hzqiuxm4周前 (04-26)回复
  11. #11

    I do not even know how I ended up here, but I thought this post was great.
    I don't know who you are but certainly you are going to
    a famous blogger if you are not already 😉 Cheers!

    minecraft1个月前 (04-23)回复
    • thanks!

      hzqiuxm4周前 (04-26)回复
  12. #12

    Hi, after reading this awesome post i am also glad to
    share my familiarity here with friends.

    minecraft4周前 (04-24)回复
  13. #13

    For hottest news you have to visit world wide web and on web I found this web page as
    a best website for most up-to-date updates.

    minecraft4周前 (04-25)回复
  14. #14

    Awesome! Its actually remarkable piece of writing,
    I have got much clear idea concerning from this paragraph.

  15. #15

    Wow, fantastic weblog structure! How lengthy have
    you been running a blog for? you made running a
    blog look easy. The entire look of your web site is wonderful, as neatly as the content material!

  16. #16

    I needed to thank you for this great read!! I definitely enjoyed every little bit
    of it. I've got you book marked to look at new things you post…

  17. #17

    Do you mind if I quote a couple of your articles
    as long as I provide credit and sources back to your site?
    My blog site is in the very same area of interest as
    yours and my users would definitely benefit from some of the information you provide
    here. Please let me know if this ok with you.
    Thanks!

  18. #18

    Great article! This is the kind of info that should be shared around the net.
    Shame on Google for now not positioning this submit upper!
    Come on over and talk over with my website . Thank you =)

    g2周前 (05-12)回复
  19. #19

    I read this piece of writing fully about the comparison of hottest
    and preceding technologies, it's amazing article.

  20. #20

    Your way of describing everything in this piece
    of writing is genuinely fastidious, every one be capable of simply
    be aware of it, Thanks a lot.

  21. #21

    It's going to be finish of mine day, but before finish I am reading this great paragraph to improve my knowledge.

  22. #22

    Stunning quest there. What occurred after?
    Take care!

  23. #23

    Incredible points. Solid arguments. Keep
    up the great effort.

  24. #24

    Hey there! Someone in my Myspace group shared this site with
    us so I came to give it a look. I'm definitely enjoying the information.
    I'm bookmarking and will be tweeting this to my followers!
    Exceptional blog and superb style and design.

  25. #25

    Ahaa, its fastidious discussion on the topic of this piece of writing here at this webpage, I have read all
    that, so now me also commenting here.

欢迎加入紫牛小筑

进入小筑关于作者