zoukankan      html  css  js  c++  java
  • ActiveMQ 集群(1)

    Queue consumer clusters(消费者集群)

      简介: 同一个queue,如果一个消费者失效, 那么任何未经确认的消息将会被发送给queue上的其它消费者。如果一个消费者比其它消费者执行的更快,它将会消费更多的消息。如果任何一个消费者执行速度变慢,那么其他消费者将来弥补空缺。所以,消费者在(队列中)处理消息时,可以有一个可靠的负载均衡。

      实现原理: 消费者对消息的处理速率可能不同,对于broker而言,它无法意识到哪个消费者处于"空闲"状态,故消费者空闲时主动向broker请求消息,如此还能有一个良好的"负载均衡".

      消费者集群不需要特殊的配置,即可使用。

      消费者集群,主要用于解决 消费者间的负载均衡 

    Broker clusters(MQ集群) 

       简介: 一个client连接多台broker中的一台(brokerA)。如果brokerA 挂了,那么client自动重新连接到其它的 broker(brokerB)。但是,brokerB并不会识别其它broker上的消费者,如果brokerB没有可识别的消费者,那么brokerB上的消息会因为得不到处理而被堆积起来。 

      目前的解决方案是使用 Network of brokers,在brokers之间实现存储转发消息。 

    2种方式实现 broker集群: 

    (1) 使用网络连接(Network of brokers)方式: 

       网络连接方式通过把多台不同的broker连接在一起,作为一个整体对外提供服务,从而提高整体对外的消息服务能力。通过这种方式,brokers可以共享队列和消费者列表,从而达到分布式队列的目的。 

       ① 可以同时运行任意多个brokerclient(broker集群 + client集群)

       ② client可连接到任意一台broker上,若这台broker挂了,client可自动重新连  接到另一台broker上。 

       实现原理通过实现静态发现或动态发现,client可以在一台broker挂了之后,自动地监测并且连接到网络中其它的broker上,同时,也可用于一台broker去发现并且连接到网络中其它的broker上。

       Netword of brokers的目的提供存储和转发消息到另一台broker上,以实现broker负载均衡,提高消息处理能力。

    (2) 使用Master/Slave方式: 

      背景由于client属于broker的,若某台broker挂了,消息只能等待broker重启后, 再被继续消费。 

      所以解决方案是,一台broker作为Master,一台broker作为Slave, 实时的把Master上的消息备份到Slave上。若Master挂了,则服务立即切换至Slave上运行。故消息不会丢失。 

       

    那么一个broker如何发现其它的broker呢? 

      通过使用静态发现或动态发现,当某台broker挂了时,client可以自动地监测到并且重新连接到网络中其它的broker上。同时,利用这个协议,broker也可以发现并且连接到网络中其它的broker上。在 ActiveMQ client通过使用 failover:// 协议来实现这个功能。 

      即client通过使用failover://协议,若broker挂了,client会自动监测到这种情况并且重新连接到其它的broker上。 

         Broker通过使用静态发现或动态发现,可以连接到其它的broker上。 

    英文参考文档:

    Broker clusters: 

      there is a collection of JMS brokers and a JMS client will connect to one of them; then if the JMS broker goes down, it will auto-reconnect to another broker. 

      We implement this using the failover:// protocol in the JMS client. See the Failover Transport Reference page for details of how to configure the failover protocol.      

      If we just run multiple brokers on a network and tell the clients about them using either static discovery or dynamic discovery then clients can easily failover from one broker to another. However stand alone brokers don't know about consumers on other brokers; so if there are no consumers on a certain broker messages could just pile up without being consumed. Currently the solution to this problem is to create a Network of brokers to store and forward messages between brokers.

    Discovery of brokers

       We support auto-discovery of brokers using static discovery or dynamic discovery so clients can automatically detect and connect to a broker from brokers, as well for brokers to discover and connect to other brokers.

     Networks of brokers

      If you have many clients and many brokers, there is a chance that one broker has producers but no consumers so that messages pile up without being processed. To avoid this ActiveMQ supports a Networks of Brokers which provides store and forward to move messages from brokers with producers to brokers with consumers which allows us to support distributed queues and topics across a network of brokers.

      This allows a client to connect to any broker - and fail over to another broker if there is a failure - providing from the clients perspective a cluster of brokers. 

      Networks of brokers also allows us to scale up to massive number of clients in a network as we can run as many brokers as we need. 

      You can think of this as a cluster of clients connecting with a cluster of brokers with auto-failover and discovery making a simple and easy to use messaging fabric.  

     

    Borker网络连接: 

      Networks of Brokers目的:提供存储转发消息到另一台broker上。 实现负载均衡,提高消息处理能力。

     

      附加: http://activemq.apache.org/clustering.html

  • 相关阅读:
    UISlider
    App两个页面之间的正反传值方法
    UIImageview的简单运用
    UIPickerview 基本使用
    IOS开发中用开关(UISwitch)跟滑块(UISlider)控制手机屏幕的亮度
    冒泡排序
    简单抽屉实现
    iOS 模态视图,视图之间的切换
    UIScrollView和UIPageControl的使用(实现图片的循环滚动)
    iOS中UIPickerView实现省/市连动
  • 原文地址:https://www.cnblogs.com/chy2055/p/5178269.html
Copyright © 2011-2022 走看看