Managing HornetQ replicated backup files
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 6.4.7
- HornetQ with replication
Issue
- I am using hornetQ with replication and I need to manage the number of replicated backup files
- Is it possible to limit the number of replicated backup files for HornetQ?
Resolution
A new parameter -Dhornetq.enforce.maxreplica was introduced in 6.4.10+ to manage the number of replicated journal files. That parameter works in parallel with <max-saved-replicated-journal-size>
Outlined below are 3 test case scenarios which should give some insight on how the parameter works
Scenario 1 Keep a predefined number of journal files. If exceeded, allow deletion of older files
Set -Dhornetq.enforce.maxreplica=false and max-saved-replicated-journal-size to 5 on the master and backup node.
- Start master node, and then backup node
- Ctrl+C or kill -9 master -> failover to backup
- Restart master node -> fails over back to master
- Repeat step 3 and 4 multiple times and you will notice:
Outcome: Once the suffix of the JBOSS_HOME/standalone/data/messagingjournal/<filename>.x exceeds 5, the older files get deleted.
Scenario 2 Keep a predefined number of journal files. If exceeded, prevent deletion of older files
Set max-saved-replicated-journal-size to 5 on the master and backup node.
- Start master node, and then backup node
- Ctrl+C or kill -9 master -> failover to backup
- Restart master node -> fails over back to master
- Repeat step 3 and 4 multiple times and you will notice:
Outcome: Once the suffix of the JBOSS_HOME/standalone/data/messagingjournal/<filename>.x is 5, the backup node stops with the message
11:39:32,293 WARN [org.hornetq.core.server] (Thread-76) HQ222163: Server is being completely stopped, since this was a replicated backup there may be journal files that need cleaning up. The HornetQ server will have to be manually restarted.
Scenario 3 Allow indefinite number of backup files
Set -Dhornetq.enforce.maxreplica=false and max-saved-replicated-journal-size to -1 on the master and backup node.
- Start master node, and then backup node
- Ctrl+C or kill -9 master -> failover to backup
- Restart master node -> fails over back to master
- Repeat step 3 and 4 multiple times and you will notice:
Outcome: The directory JBOSS_HOME/standalone/data/messagingjournal/<filename>.x grows indefinitely and will require a manual clean up
NOTE:
As a general guide, consider setting -Dhornetq.enforce.maxreplica=false and max-saved-replicated-journal-size to a min of 3 and max of 5.
To summarise max-saved-replicated-journal-size settings:
-1 => infinite number of old replicas are preserved
0 => keep 0 replicas
1 => 1 old replica is preserved.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.