Discover Domain controllers in WildFly
A new feature of WildFly 8 is the ability to allow Domain Discovery which allows reconnecting to one or more alternate Domain controller, in case the default one fails.
Let’s see an example of it:
<domain-controller>
<remote host="${jboss.domain.master.address:127.0.0.1}" port="${jboss.domain.master.port:9999}" security-realm="ManagementRealm">
<discovery-options>
<static-discovery name="discovery-one"
protocol="${jboss.domain.master.protocol:remote}"
host="${jboss.domain.master.address:127.0.0.1}"
port="${jboss.domain.master.port:19999}"/>
</discovery-options>
</remote>
</domain-controller>
In the above example, we have included a static-discovery section which will kick in if there is a failure with the default remote host. (To keep it simple, the master address is on the same machine but with a different port).
You can easily test this scenario:
- Start the Domain Controller on port 9999
- Join the Slave Host Controller
- Shutdown the Domain Controller
- Restart another Domain Controller on Port 19999

As you can see from the logs, after the initial failure, the Host Controller discovers the new Domain Controller on port 19999 and reconnects to it:
[Host Controller] 16:16:12,500 WARN [org.jboss.as.host.controller] (Remoting "slave:MANAGEMENT" task-3) WFLYHC0015: Connection to remote host-controller closed. Trying to reconnect.
[Host Controller] 16:16:12,502 INFO [org.jboss.as.host.controller] (Host Controller Service Threads - 8) WFLYHC0150: Trying to reconnect to master host controller.
[Host Controller] 16:16:13,510 INFO [org.jboss.as.host.controller] (Host Controller Service Threads - 8) WFLYHC0150: Trying to reconnect to master host controller.
[Host Controller] 16:16:17,514 INFO [org.jboss.as.host.controller] (Host Controller Service Threads - 8) WFLYHC0150: Trying to reconnect to master host controller.
[Host Controller] 16:16:26,519 INFO [org.jboss.as.host.controller] (Host Controller Service Threads - 8) WFLYHC0150: Trying to reconnect to master host controller.
[Host Controller] 16:16:41,522 INFO [org.jboss.as.host.controller] (Host Controller Service Threads - 8) WFLYHC0150: Trying to reconnect to master host controller.
[Host Controller] 16:16:56,525 INFO [org.jboss.as.host.controller] (Host Controller Service Threads - 8) WFLYHC0150: Trying to reconnect to master host controller.
[Host Controller] 16:16:56,980 INFO [org.jboss.as.host.controller] (Host Controller Service Threads - 8) WFLYHC0148: Connected to master host controller at remote://127.0.0.1:19999
You are not limited to have a single discovery options: you can have multiple discovery options which will be sequentially tried in case of failure:
<domain-controller>
<remote host="${jboss.domain.master.address:127.0.0.1}" port="${jboss.domain.master.port:9999}" security-realm="ManagementRealm">
<discovery-options>
<static-discovery name="discovery-one"
protocol="${jboss.domain.master.protocol:remote}"
host="${jboss.domain.master.address:127.0.0.1}"
port="${jboss.domain.master.port:19999}"/>
<static-discovery name="discovery-two"
protocol="${jboss.domain.master.protocol:remote}"
host="${jboss.domain.master.address:127.0.0.1}"
port="${jboss.domain.master.port:29999}"/>
</discovery-options>
</remote>
</domain-controller>
Recommended Articles
High Availability with WildFly: Ensuring Java EE App Uptime and Performance
Learn how to configure high availability in WildFly, a robust framework for Java EE applications. Discover the role of failover, load balancing, and other subsystems in ensuring seamless application operation.
Cluster Web Applications Using WildFly Application Server
Learn how to cluster a web application with WildFly and JBoss AS 5. Improve scalability and availability with our expert guide.
Mastering JBoss CLI Scripts for Domain Mode Operations
Learn how to configure resources, reach server nodes, and manage server groups with JBoss CLI scripts in domain mode.
Mastering WildFly Clustering for High Availability with Infinispan
Learn how to set up WildFly clustering using Infinispan for seamless failover and data synchronization. #WildFly #Infinispan #JavaClustering