Message must be persisted
Primary service-side configuration file:
Hornetq-configure.xml add
Persistent configuration
<persistence-enabled>true</persistence-enabled>
Connectors for connecting to the backup server
<backup-connector-ref connector-name= "Backup-connector"/>
<connectors>
......
Standby connectors
<connector name= "Backup-connector" >
<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
<param key= "host" value= "172.20.16.191"/>
<param key= "Port" value= "5445"/>
</connector>
</connectors>
Hornetq-jms.xml add
Add property backup-connector-name to Connection-factory.connectors.connector-ref.
Add Failover-on-server-shutdown in Connection-factory and set to true to indicate failure relief when ctrl-c stops the server.
Specific configuration See below:
<connection-factory name= "Nettyconnectionfactory" >
<connectors>
<connector-ref connector-name= "Netty" backup-connector-name= "Backup-connector"/>
</connectors>
<entries>
<entry name= "ConnectionFactory"/>
<entry name= "/xaconnectionfactory"/>
</entries>
<failover-on-server-shutdown>true</failover-on-server-shutdown>
</connection-factory>
From the server-side configuration file:
Hornetq-configure.xml add
Persistent configuration
<persistence-enabled>true</persistence-enabled>
is a backup server
<backup>true</backup>
Note:
1, first start from the service side, and then start the main service side.
2, the master and subordinate data to be consistent.
3, the above configuration is to use data replication to ensure that the master-slave data consistency, there is another way is storage sharing, using storage sharing is required in the master-slave server Hornetq-configure.xml to add the following configuration:
Whether to share storage
<shared-store>true</shared-store>
Data directory set to shared directory
<paging-directory>shared-dir/data/paging</paging-directory>
<bindings-directory>shared-dir/data/bindings</bindings-directory>
<journal-directory>shared-dir/data/journal</journal-directory>
<large-messages-directory>shared-dir/data/large-messages</large-messages-directory>