Highly Available AMQP via Spring Integration and RabbitMQ

WHAT I DID:

I am using RabbitMQ message broker which supports the AMQP standard in my spring micro services. Its main purpose is to prevent the message losing, during the rabbitMQ server (unfortunate) shutdown. So I am planning to give the Highly Available AMQP Backed Message Channels.

I tried to setup two RabbitMQ servers and I followed the below link to setup the RabbitMQ servers.

https://dzone.com/articles/highly-available-amqp-backed

First RabbitMQ Server' s config file(rabbitmq.config) is as follows. It should be put under ../rabbitmq_server-version/etc/rabbitmq/

[
 {rabbit, [ {tcp_listeners, [5672]},
 {collect_statistics_interval, 10000},
 {heartbeat,30},
 {cluster_partition_handling, pause_minority},
 {cluster_nodes, {[ 'rabbit@master',
                    'rabbit2@master'],
                  disc}} ] },
 {rabbitmq_management, [ {http_log_dir,"/tmp/rabbit-mgmt"},{listener, [{port, 15672}]} ] },
 {rabbitmq_management_agent, [ {force_fine_statistics, true} ] }
].

Second RabbitMQ Server' s rabbitmq.config file :

[
 {rabbit, [ {tcp_listeners, [5673]},
 {collect_statistics_interval, 10000},
 {heartbeat,30},
 {cluster_partition_handling, pause_minority},
 {cluster_nodes, {[ 'rabbit@master',
                    'rabbit2@master'],
                  disc}} ] },
 {rabbitmq_management, [ {http_log_dir,"/tmp/rabbit-mgmt"},{listener, [{port, 15673}]} ] },
 {rabbitmq_management_agent, [ {force_fine_statistics, true} ] }
].

First RabbitMQ Server' s sample bash script is as follows. Also please have a look RabbitMQ Cluster documentation for other configuration steps.

#!/bin/bash
echo "*** First RabbitMQ Server is setting up ***"

export RABBITMQ_HOSTNAME=rabbit@master
export RABBITMQ_NODE_PORT=5672
export RABBITMQ_NODENAME=rabbit@master
export RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15672}]"

/DEV_TOOLS/rabbitmq_server-3.4.2/sbin/rabbitmq-server &

echo "*** Second RabbitMQ Server is set up succesfully. ***"

sleep 5

echo "*** First RabbitMQ Server' s status : ***"

/DEV_TOOLS/rabbitmq_server-3.4.2/sbin/rabbitmqctl status

Second RabbitMQ Server' s sample bash script is as follows :

#!/bin/bash
echo "*** Second RabbitMQ Server is setting up ***"

export RABBITMQ_HOSTNAME=rabbit2@master
export RABBITMQ_NODE_PORT=5673
export RABBITMQ_NODENAME=rabbit2@master
export RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15673}]"

/DEV_TOOLS/rabbitmq_server-3.4.2_2/sbin/rabbitmq-server &

echo "*** Second RabbitMQ Server is set up succesfully. ***"

sleep 5

echo "*** Second RabbitMQ Server' s status : ***"

/DEV_TOOLS/rabbitmq_server-3.4.2_2/sbin/rabbitmqctl status

sleep 5

echo "*** Second RabbitMQ Server is being added to cluster... ***"

/DEV_TOOLS/rabbitmq_server-3.4.2_2/sbin/rabbitmqctl -n rabbit2@master stop_app
/DEV_TOOLS/rabbitmq_server-3.4.2_2/sbin/rabbitmqctl -n rabbit2@master join_cluster rabbit@master
/DEV_TOOLS/rabbitmq_server-3.4.2_2/sbin/rabbitmqctl -n rabbit2@master start_app
/DEV_TOOLS/rabbitmq_server-3.4.2/sbin/rabbitmqctl -n rabbit@master set_policy ha-all "^ha." '{"ha-mode":"all"}'

echo "*** Second RabbitMQ Server is added to cluster successfully... ***"

sleep 5

echo "*** Second RabbitMQ Server' s cluster status : ***"

/DEV_TOOLS/rabbitmq_server-3.4.2_2/sbin/rabbitmqctl cluster_status

WHAT IS ISSUE:

I can see that two RabbitMQ servers are running synchronously.

When I stop the first node, the second node is working.

sbin/rabbitmqctl stop_app

But When I shut down the first RabbitMQ server, the second node also going down.

sbin/rabbitmqctl stop

But, The result should be,

If First Messaging Node and First RabbitMQ Server are shut down accidentally, Second Messaging Node and Second RabbitMQ Server will continue to process Order messages so potential message loosing and service interruption problems can be prevented by using high available AMQP backed channel.

Kindly help me to fix this issue. Thanks.

链接地址: http://www.djcxy.com/p/34106.html

上一篇: 通过AMQP上的STOMP创建的访问/队列或/主题

下一篇: 通过Spring集成和RabbitMQ提供高度可用的AMQP