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>
Found the article helpful? if so please follow us on Socials