<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.3 20210610//EN" "https://jats.nlm.nih.gov/publishing/1.3/JATS-journalpublishing1-3.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.3" xml:lang="en" article-type="research-article"><front><journal-meta><journal-id journal-id-type="publisher-id">jcse</journal-id><journal-title-group><journal-title>Journal of Computational Science and Engineering</journal-title></journal-title-group><issn>1710-4068</issn><publisher><publisher-name>Advancersin</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="publisher-id">jcse-v8-a05</article-id><article-categories><subj-group subj-group-type="heading"><subject>Research Article</subject></subj-group></article-categories><title-group><article-title>Design and Realization of ActiveMQ Based High Performance Message Cluster</article-title></title-group><contrib-group><contrib contrib-type="author"><name name-style="western"><surname>Chen</surname><given-names>Guangxuan</given-names></name><xref ref-type="aff" rid="aff-1"/></contrib><contrib contrib-type="author"><name name-style="western"><surname>Du</surname><given-names>Yanhui</given-names></name><xref ref-type="aff" rid="aff-1"/></contrib><contrib contrib-type="author"><name name-style="western"><surname>Qin</surname><given-names>Panke</given-names></name><xref ref-type="aff" rid="aff-2"/></contrib><contrib contrib-type="author"><name name-style="western"><surname>Zhang</surname><given-names>Lei</given-names></name><xref ref-type="aff" rid="aff-3"/></contrib></contrib-group><aff id="aff-1">People’s Public Security University of China, Beijing, China</aff><aff id="aff-2">Beijing University of Posts and Telecommunications, Beijing, China</aff><aff id="aff-3">The Logistics Academy, Beijing, China</aff><pub-date publication-format="electronic" date-type="pub" iso-8601-date="2013"><year>2013</year></pub-date><volume>8</volume><fpage>310</fpage><lpage>313</lpage><permissions><copyright-statement>2013 © The American Computational Science Society.</copyright-statement><license license-type="open-access" xlink:href="https://creativecommons.org/licenses/by/4.0/"><ali:license_ref xmlns:ali="http://www.niso.org/schemas/ali/1.0/" start_date="2021-11-26">https://creativecommons.org/licenses/by/4.0/</ali:license_ref><license-p>This article is licensed under the Creative Commons Attribution 4.0 International license (CC BY 4.0), which permits sharing and adaptation, including commercial reuse, subject to attribution, a link to the license and an indication of changes. Third-party material separately credited with different terms is governed by the license or rights notice stated for that material.</license-p></license></permissions><self-uri content-type="fulltext" xlink:href="https://www.advancersin.org/jcse/articles/jcse-v8-a05/index.html"/><self-uri content-type="pdf" xlink:href="https://www.advancersin.org/jcse/articles/jcse-v8-a05/jcse-v8-a05.pdf"/><abstract><p>In order to solve the performance bottleneck problems and enhance the reliability of the message cluster, this paper proposed a new solution. By introducing ActiveMQ component and message agent, the message cluster can extend the single middleware into the message middleware environment, and thus improved the availability of the data in the shared file system and database. Meanwhile, a new algorithm and mechanism of load balancing, data synchronization and fault recovery are introduced into the message cluster that greatly enhanced the performance and reliability of the cluster.</p></abstract><kwd-group><kwd>ActiveMQ</kwd><kwd>Data synchronization</kwd><kwd>Fault recovery</kwd><kwd>Load balancing</kwd><kwd>Message cluster</kwd></kwd-group></article-meta></front><body>
    <sec>
      <title>Introduction</title>
      <p>With the rapid development of internet, network servers must pos sess strong network computing processing power and ability of providing a large number of concurrent access services so as to better deal with the sharp increase of accesses and even complicated transactions. However, the limit of processing power, memory, I/O and bandwidth of the single network server became the bottleneck in facing the large number of tasks. Traditional way to solve these problems is to adopt expensive high performance mainframe or SMP computer. This is not always effective when more proc essing requests and data surge to the server. In addition, the low efficiency and unreliable transmission among different hardware platform and different network</p>
      <p>(2013) -</p>
      <p>© The American Computational Science Society. All rights reserved.</p>
      <p>environment also bothered the customers [1].</p>
      <p>In order to solve these problems, middleware and cluster are introduced in the study. Middleware is first used to solve distributed heterogeneous problems. Its main purpose is to shield the heterogeneity an d complexity of the distributed environment and provide isomorphic distributed development plat form for the users and developers.</p>
      <p>Cluster refers to a group of independent servers in the network that provide reliable service for the users as a single system. Higher performance, higher performance to price ratio, better flexibility and higher avail ability made cluster system can effectively solve the bottlenecks and enhance the availability of the system in dealing with large scale requests and tasks. In the following text, we proposed a new solution of cluster, an ActiveMQ and message agent based c luster system that possesses high performance and reliability.</p>
      <p>2.</p>
      <p>ActiveMQ Component</p>
      <p>Apache ActiveMQ is a fast open source message component that supports clustering, lightweight container and Java virtual machine of most cross language clients and can se amlessly integrates with the J2EE1.4 container. ActiveMQ supports two types of message transmission mode, i.e., Point to - Point mode and Publisher/Subscriber mode [2]. This paper adopted Point to - Point mode, its development flow is introduced as follows.</p>
      <p>Pr oducer’s</p>
      <p>development flow. The Producer generates messages (shown in Figure 1):</p>
      <p>● Create Connection: create a JMS Connection according to the url, user and password.</p>
      <p>● Create Session: create a Session on the base of Connection and indicate whether support transaction and ACKNOWLEDGE.</p>
      <p>● Create object Destination: specify the name of the subject; the producer and consumer will send and receive the corresponding message through the subject.</p>
      <p>● Create MessageProducer: create object MessageProducer according to Destination, and set the persistent mode at the same time.</p>
      <p>● Send message to Qu eue: encapsulate TextMessage and send out the message through the send method of MessageProducer.</p>
      <p>Fi g.</p>
    </sec>
    <sec>
      <title>1 Producer’s workflow</title>
      <p>– Send message</p>
      <p>Consumer’s development flow. Consumer consumes the messages (shown in Figure 2):</p>
      <p>● Implement interface MessageLi stener: class consumer should first implement the interface MessageListener, and then monitors and processes the messages through method onMessage().</p>
      <p>● Create Connection: create a JMS Connection according to url, user and password. A clientID is needed for the Connection if the Connection is under durable mode.</p>
      <p>● Create Session and Destination: similar to that in producer’s development flow.</p>
      <p>● Create replyProducer (optional): replyProducer is used to send replies to the producer.</p>
      <p>● Create MessageConsumer: create Message</p>
      <p>Consumer according to the Destination.</p>
      <p>● Consume message: receive the messages from producer through method on</p>
      <p>Message and send replies to producer through method replyProducer.</p>
      <p>Fig .</p>
    </sec>
    <sec>
      <title>2 Consumer’s workflow</title>
      <p>– Receive message</p>
      <p>(2013) -</p>
      <p>© The American Computational Science Society. All rights reserved.</p>
      <p>ActiveMQ Clust er</p>
      <p>Integral Structure of ActiveMQ based cluster.</p>
      <p>The ActiveMQ based cluster is consisted of client agent, load balancer and server.</p>
      <p>● Agent: Agents are used to shield the underlying differences between the system and the networks so as to realize the tra nsparent transmission among application layers. In addition, agents help the clients send the messages.</p>
      <p>● Load balancer: Load balancer is used for maintaining the connections between agents and servers and recording the locations of the queues and subjects . Load balancers are connected through high speed intranet and each of them is connected to all the servers in the system. Most of the time, load balancer transmits clients’ tasks and calculates the servers’ load. Load balancer forms a many to many relatio nship between clients and servers. This makes it possible that one client can access multiple queues on different servers, or one server can process multiple accesses from different clients.</p>
      <p>● Server: Servers are responsible for the storage and transmission of the messages.</p>
      <p>The whole structure between agents and servers can be seen as middleware. While, the agent, load balancer and server formed a message middleware system that supporting cl uster. As can be seen from Figure 3, server 1 and server 2 share the queues and subjects that originally should accomplished by one server. Ideally, this new solution doubled the transmission efficiency [2].</p>
      <p>Fig .</p>
    </sec>
    <sec>
      <title>3 Integral structure of ActiveMQ based m</title>
      <p>essage cluster</p>
      <p>ActiveMQ’s function.</p>
      <p>ActiveMQ implements the function of cluster server through message agent. The message agents in the same network are visible to the others and keep communication with each other. All the clients are equipped with agent s and communicate with each other through agents.</p>
      <p>On the whole, each client exhibits an agent to the outside. All the agents share the common file system and database. If one client downtime, the other agents will take over its tasks in order to guarante e the cluster run smoothly. Looking into the inside of the clients, each client equipped with multiple message agents, but only one agent will provide service for the outside in the same time period and the other agents will act as slave machines. Once the master server is downtime, the client will immediately enable the slave servers to take over master server’s tasks. Sharing the file system and database between the master and slave servers can ensure the high availability and reliability of the data.</p>
      <p>I n order to guarantee the performance and rate of the transmission of the messages, each server is equipped with a standby. By transparently increasing the number of server to share the same number of queues and subjects, each server will bear less number o f queues and subjects and thus the efficiency of accessing and transmitting the message will enhanced obviously.</p>
      <p>3.</p>
      <p>Optimization mechanism for the cluster</p>
      <p>In order to optimize the performance of the cluster, load balancing, data synchronization and fault r ecovery are introduced into the cluster.</p>
      <p>Load balancing. Load balancing is achieved through two levels. The first level is load balancing among different load balancers. The user specifies one or multiple load balancers for the agent. The agent will fir st judge the load status of the load balancer and then choose the active one with the lightest load according to the load balancing algorithm.</p>
      <p>(2013) -</p>
      <p>© The American Computational Science Society. All rights reserved.</p>
      <p>The second level refers to the load balancing between servers. The load balancer will choose a server with the lightest load to establish queue/subject according to the weighted algorithm, shown in Eq. 1.</p>
      <p>net O I mem cpu L k L k L k L k s L         / ) ( .</p>
      <p>(1)</p>
      <p>Here,</p>
      <p>) ( s L</p>
      <p>refers to the load of the server; cpu L means the cpu occupancy of the server; mem L</p>
      <p>is the utilization ratio; O I L /</p>
      <p>is the I/O status and</p>
      <p>net L is the bandwidth occupancy. k , k , k and k are weight factors. Bandwidth is relative important in the message cluster, so we can increase the weight of bandwidth a ccordingly. For example, the weight can be assigned as . , .     k k k k .</p>
      <p>Data synchronization. Data synchronization in the cluster system reflects in two aspects: data synchronization of queue/subject tables among load balancers and data synchron ization between master servers and hot standbys.</p>
      <p>As for the first one, each load balancer maintains its own index. When the required queue is not available or failed to open the specific queue in the index, the data synchronization mechanism will maintai n that the index is error and then retrieve the queue/subject tables from each servers and generate global queue/subject table.</p>
      <p>As for the second one, only the master server provides services for the outside at a certain moment, while the hot standby on ly stores the relative data. The master server and hot s tandby both adopt duplex service software to monitor each other’s running status. The well run one will aware the failures of the one at the other end and take corresponding measures when one of them is downtime.</p>
      <p>Fault recovery.</p>
      <p>Throughout the cluster syst em, load balancer and servers need fault recovery mechanism in case of downtime.</p>
      <p>As for the load balancer, fault recovery is not necessary if there is multiple load balancers in the cluster as if one of them downtime will not affect the work of the enti re cluster. The client will automatically search and reconnect to the load balancer with the lowest load in the cluster according to the optimization rule when they lose connection with the original load balancer.</p>
      <p>However, hot standby is necessary if there is only one load balancer in the cluster system. The standby will maintain the content of queue/subject tables and connection tables in real time.</p>
      <p>As for the servers, each server adopts hot standby for fault recovery. The hot standby will take over the master server’s tasks when it is downtime.</p>
      <p>4.</p>
    </sec>
    <sec>
      <title>Conclusion</title>
      <p>The limit of processing power, memory, I/O and bandwidth of the single network cluster became the bottlenecks in facing large scale of requests and processing tasks. The ActiveMQ based message clus ter we designed can effectively release the processing stress that bothered the clients. By introducing load balancing, data synchronization and fault recovery, the performance and reliability of the cluster enhanced greatly. Meanwhile, the availability an d manageability of the data in the cluster also improved obviously.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref-001">
        <mixed-citation>[1] Y.T. Huang, Q.K. Chen, Computer Applications, 1 (2008) 52-55.</mixed-citation>
      </ref>
      <ref id="ref-002">
        <mixed-citation>[2] B. Synder, D. Bosanac, R. Davies, ActiveMQ in Action, Manning, New York, 2011.</mixed-citation>
      </ref>
    </ref-list>
  </back>
  <floats-group>
    <fig id="fig-001" position="float">
      <graphic xlink:href="figures/fig-001.jpg"/>
    </fig>
    <fig id="fig-002" position="float">
      <graphic xlink:href="figures/fig-002.jpg"/>
    </fig>
    <fig id="fig-003" position="float">
      <graphic xlink:href="figures/fig-003.jpg"/>
    </fig>
  </floats-group>
</article>
