Steps to make an existing JNDI HornetQ service as HA?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
HornetQ is a high-performance, multi-protocol messaging system that is built for the WildFly application server. By default, a HornetQ instance runs in a non-HA mode, which can be a limiting factor for systems that require high availability (HA). This article aims to provide detailed steps to convert an existing JNDI-based HornetQ service into a highly available service. High availability ensures that your messaging service remains operational, even in case of server failures.
Setting Up the Environment
Before you start configuring HA for HornetQ, you must have the following prerequisites:
- Clustered Environment: Ensure that you have at least two WildFly application servers running.
- Network Setup: The servers must be able to communicate with each other.
- Backup Servers: Prepare secondary servers that will take over the operations if a primary server fails.
Steps to Make HornetQ HA
1. Configuring Shared Storage
For HA, HornetQ requires a shared storage or a replicated setup to ensure data consistency among servers.
- Shared Store Configuration: You can use NFS, SAN, or any shared file system.
- JDBC Store: For database-backed solutions, configure your datasource to enable a shared database.
2. Setup Clustering
- Cluster Configuration: In the
standalone-ha.xmlfile of WildFly, locate the<hornetq-server>element and add cluster connections.
3. Configuring HA Policy
- Replication Policy: Modify the
<ha-policy>tag to enable replication.
- Shared Store: Alternatively, use shared-store as HA policy if shared storage is set up.
4. Define Backup Server
- Backup Servers: Specify which servers will play primary and backup roles.
5. Configuring JNDI
Appropriately configure your JNDI resources to point to the primary and backup servers.
- Initial Context Factory: Point to the appropriate URL of the HA cluster.
6. Testing Your Configuration
After configuration, ensure that your setup works as expected:
- Use
jconsoleor any JMX client to monitor the status of your servers. - Restart the primary server and observe whether the backup server takes over seamlessly.
Common Issues and Troubleshooting
- Network Partitioning: In a network partition, ensure your backup can connect to the primary.
- Access Control: Ensure that the correct security settings are enabled for JNDI resources.
- Resource Locks: Shared storage can have issues with locks; configure a timeout or retry logic.
Conclusion
Implementing a high-availability setup for your HornetQ service significantly improves system reliability and uptime. By configuring clustering, shared or replication storage, HA policies, and backup servers, you ensure that your service continues to function even during failures.
Summary Table
Below is a summary table of the configuration changes and settings required:
| Component | Configuration |
| Storage | Shared Store or Replicated |
| Cluster Setup | <cluster-connection> with static-connectors |
| HA Policy | <replication> or <shared-store> configured |
| JNDI | Context.PROVIDER_URL with multiple endpoints |
| Role Definitions | Set master/backup roles in the HA policy |
| Monitoring Tools | jconsole for JMX monitoring |
By following these steps, administrators can transition an existing JNDI HornetQ service to an HA architecture, ensuring minimal downtime and potential failure mitigation.
Related reading
- Storm-Kafka multiple spouts, how to share the load?
- Strategy to keep local cache see the same version of data in a distributed system
- Streaming from particular partition within a topic (Kafka Streams)
- Streaming messages from one Kafka Cluster to another
- Strict serializability example clarification?
- Strong Consistency in Cassandra
- Strong Consistency vs. Read-after-write Consistency
- Stuck with understanding how to build a scalable system

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.