Another talk about Apache ActiveMQ load Balancing

Source: Internet
Author: User
Tags amq


The previous article, "Apache ActiveMQ load Balancer," at the end of a scenario, that is, when the number of nodes in the AMQ is greater than 2 (HA + LB), and configured the message reflow situation of some problems.



The basic structure of HA + lb is shown below:






The problem occurs when a producer posts a message to the master node (AMQ SERVER), the consumer establishes a connection (Broker) with a node, and consumes a certain number of messages in advance based on AMQ's "pre-consumption" policy, that is, a node consumes part of the master node's message. The a node forwards the message to the consumer consumer.



Consumer in the process, a node unplanned downtime, consumers according to the failover mechanism will automatically connect to the B or C node, want to continue to consume the remaining messages (a node not consume the completed message).






Then we can solve the problem in this scenario as follows:


The < beans

XMLNS = "http://www.springframework.org/schema/beans"

XMLNS: xsi = "http://www.w3.org/2001/XMLSchema-instance"

Xsi: schemaLocation = "HTTP: / / http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd ">


<!--</span--> Allows us to use system properties as variables in this configuration file

The < bean class = "org. Springframework. Beans. Factory. Config. Accomplished" >

The < property name = "locations" >

< value > file: ${activemq. Conf} / credentials. The properties value > < /

< / property >

< / bean >


<!--</span--> --

The

element is used to configure The ActiveMQ broker.</broker>

-->

< broker XMLNS = "http://activemq.apache.org/schema/core" brokerName = "broker129 dataDirectory" = "${activemq. Data}" >


<!--</span--> Destination specific policies using Destination names or wildcards ->

The < destinationPolicy >

The < policyMap >

The < policyEntries >

The < policyEntry topic = "> >"

< / policyEntry >

< policyEntry queue = ">" enableAudit = "false" >

The < deadLetterStrategy >

The < individualDeadLetterStrategy queuePrefix = "DLQ." useQueueForQueueMessages = "true" / >

< / deadLetterStrategy >

The < networkBridgeFilterFactory >

The < conditionalNetworkBridgeFilterFactory replayWhenNoConsumers = "true" / >

< / networkBridgeFilterFactory >

< / policyEntry >

< / policyEntries >

< / policyMap >

< / destinationPolicy >


<!--</span--> --

The managementContext is used to configure how ActiveMQ is exposed in

Jmx. By default, ActiveMQ USES the MBean server that is started By

The JVM. For more information, see:


http://activemq.apache.org/jmx.html

-->

The < managementContext >

The < managementContext createConnector = "false" / >

< / managementContext >


<!--</span--> --

Duplex Broker mode, that is, a Broker can be a consumer or a publisher.

This parameter is different from "message reflow" (replayWhenNoConsumers).

-->

<!--</span--> -- networkTTL: the number of brokers through which information and subscriptions can pass over the network. This parameter needs to be set reasonably according to the LB quantity ->

The < networkConnectors >

< networkConnector duplex = "true" networkTTL = "3" uri = "static: (TCP: / / 192.168.137.200:61616)" / >

< / networkConnectors >


<!--</span--> --

Configure message persistence for the broker. The default persistence

Mechanism is the KahaDB store (identified by the KahaDB tag).

For more information, see:


http://activemq.apache.org/persistence.html

-->

The < persistenceAdapter >

< kahaDB directory = "${activemq. Data} / kahaDB" / >

< / persistenceAdapter >



<!--</span--> --

The systemUsage controls The maximum amount of space The broker will

Use before disabling caching and/or slowing down producers. For more information, see:

http://activemq.apache.org/producer-flow-control.html

-->

The < systemUsage >

The < systemUsage >

The < memoryUsage >

The < memoryUsage percentOfJvmHeap = "70" / >

< / memoryUsage >

The < storeUsage >

< storeUsage limit = "100 gb" / >

< / storeUsage >

The < tempUsage >

< tempUsage limit = "50 gb" / >

< / tempUsage >

< / systemUsage >

< / systemUsage >


<!--</span--> --

The transport connectors expose ActiveMQ over a given protocol to

Clients and other brokers. For more information, see:


http://activemq.apache.org/configuring-transports.html

-->

The < transportConnectors >

<!--</span--> DOS protection, limit concurrent connections to 1000 and frame size to 100MB

The < transportConnector name = "openwire" uri = "nio: / / 0.0.0.0:61616? MaximumConnections = 1000 & wireFormat. MaxFrameSize = 104857600 "/ >

< / transportConnectors >


<!--</span--> -- destroy the spring context on shutdown to stop jetty -->

The < shutdownHooks >

The < bean XMLNS = "http://www.springframework.org/schema/beans" class = ". Org. Apache activemq. Hooks. SpringContextHook "/ >

< / shutdownHooks >


< / broker >


<!--</span--> --

The Enable web consoles, REST and Ajax APIs and demos

The web consoles The requires by default login, you can disable this in The jetty. The XML file


Take a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details

-->

The < import resource = "jetty. XML" / >


< / beans >























Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.