Thursday, March 27, 2014

How to set jvmRoute in JBoss EAP 6 or JBoss CE 7

For session stickiness, failover and loadbalancing support mod_jk/mod_cluster relies on a jvmRoute property set at JBoss EAP/CE configuration. If you are using mod_jk, make sure that jvmRoute attribute is set and that the jvmRoute attribute value matches your worker name in workers.properties.

Set instance-id="<value>" on the web subsystem.


  • Using CLI:

     /subsystem=web:write-attribute(name=instance-id,value=<value>)  

  • XML (standalone.xml / domain.xml):

    <subsystem xmlns="urn:jboss:domain:web:1.1" ... instance-id="<value>">
or

Set jvmRoute system property.


  • Using CLI:

      /system-property=jvmRoute/:add(value=<value>,boot-time=true)   

  • XML (standalone.xml / domain.xml):

         <system-properties>
<property name="jvmRoute" value="<value>"/>
 </system-properties>

Note that the instance-id setting gets preference over the jvmRoute system property if you specify both settings at once.

You can use expressions in the instance-id like instance-id="${my.jvmRoute}" and override the value using standalone.sh option (or Java VM option). For example:
$JBOSS_HOME/bin/standalone.sh -Dmy.jvmRoute=node1
Usually you need to specify unique value to jboss.node.name system property for each node in cluster environment. So you may set the instance-id like instance-id="${jboss.node.name}" then specify unique jboss.node.name to standalone.sh like:
$JBOSS_HOME/bin/standalone.sh -Djboss.node.name=node1

Note that be careful to use jboss.node.name (or jboss.server.name) system properties in domain environment. they are set automatically based on host configuration by default. jboss.node.name is "hostname:servername" format by default and it contains colon character (":") which is not a valid worker name for mod_jk.
The name of the worker can contain only the alphanumeric characters [a-z][A-Z][0-9][_-] and is case sensitive. And jboss.server.name is not unique across hosts, so you have to make sure to set them unique value.