4 Replies Latest reply on Jun 27, 2013 8:34 AM by Doug Grove

    Externalizing resource adapter configs from standalone.xml in Jboss-as 7.1.1

    nav Newbie

      Hi everyone

       

      I'm using Jboss-as 7.1.1

       

      I have configured the resource adapter as below in the standalone.xml file. This basically is the configuration for a outbound queue using Websphere MQ and it works fine.

       

       

      <subsystem xmlns="urn:jboss:domain:resource-adapters:1.0">
                  <resource-adapters>
                      <resource-adapter>
                          <archive>
                              wmq.jmsra.rar
                          </archive>
                          <transaction-support>NoTransaction</transaction-support>
                          <connection-definitions>
                              <connection-definition class-name="com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl" jndi-name="java:jboss/jms/MQConnectionFactory" enabled="true" use-java-context="false" pool-name="MqConnectionFactoryPool">
                                  <config-property name="port">
                                      3434
                                  </config-property>
                                  <config-property name="hostName">
                                      myhost
                                  </config-property>
                                  <config-property name="channel">
                                      CLIENT.TO.AUIHTA01
                                  </config-property>
                                  <config-property name="transportType">
                                      CLIENT
                                  </config-property>
                                  <config-property name="queueManager">
                                      AUIHTA01
                                  </config-property>
                              </connection-definition>
                          </connection-definitions>
                          <admin-objects>
                              <admin-object class-name="com.ibm.mq.connector.outbound.MQQueueProxy" jndi-name="java:jboss/jms/MQOutboundQueue" enabled="true" use-java-context="false" pool-name="MyQueue1Pool">
                                  <config-property name="baseQueueManagerName">
                                      AUIHTA01
                                  </config-property>
                                  <config-property name="baseQueueName">
                                      XX.CBO.OUT
                                  </config-property>
                              </admin-object>
                          </admin-objects>
                      </resource-adapter>
                  </resource-adapters>
              </subsystem>
      

       

       

      My requirement is that I need to externalise the configs such as hostName, port etc. This is because I want to change it based on different environments such as development,QA,Live etc.

      Basically I want to know if these parameters can be externalised to a file so that it can be incuded in my deployment war file or ear file.

       

       

      Thanks!

        • 1. Re: Externalizing resource adapter configs from standalone.xml in Jboss-as 7.1.1
          nav Newbie

          Seem's this is not possible. Jboss 7.1.1 simply doesn't allow it. Bit of a disconnect here because your MDB queue details will will be bundled in your application in a ejb-war.xml file but your outbound queue will remain out of your deployment.

          • 2. Re: Externalizing resource adapter configs from standalone.xml in Jboss-as 7.1.1
            Doug Grove Newbie

            This is certainly possible.  Note that JBoss supports a variety of property substitutions.  For example, in the standalone.xml file, you could have:

             

                <system-properties>

                    <property name="wmq.host" value="10.0.0.150"/>

                    <property name="wmq.port" value="1414"/>

                </system-properties>

             

            Then:

             

                                <connection-definitions>

                                    <connection-definition class-name="com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl" jndi-name="java:/WSMQ" enabled="true" pool-name="WSMQ" use-ccm="true">

                                        <config-property name="port">

                                            ${wmq.port}

                                        </config-property>

                                        <config-property name="hostName">

                                            ${wmq.host}

                                        </config-property>

             

            This applies as well to ejb-jar.xml files and jboss.xml files.  Ensure that the proper property substitutions are enabled in standalone.xml:

             

                    <subsystem xmlns="urn:jboss:domain:ee:1.1">

                        <spec-descriptor-property-replacement>true</spec-descriptor-property-replacement>

                        <jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>

                    </subsystem>

             

             

             

            Hope that helps,

             

            Doug

            • 3. Re: Externalizing resource adapter configs from standalone.xml in Jboss-as 7.1.1
              nav Newbie

              Hi Doug,

               

              Thanks for the response but, the requirement is to have different configs for say DEV, TEST and production, and have jboss pick these up dynamically.

               

              So lets say, a config file/property file will be created by my build and on jboss startup it will read those values and substitute them in standalone.xml

               

              If we hard code the properties in the standalone.xml file as system properties it doesn't change anything, it's still hard coded in standalone.xml and cant be dynamically changed

               

              Hope thats clear.

               

              Navanga

              • 4. Re: Externalizing resource adapter configs from standalone.xml in Jboss-as 7.1.1
                Doug Grove Newbie

                I understand what you are going for.   I was simply pointing out that all of the needed mechanisms are in place.  Configure your ejb-jar.xml, jboss.xml and standalone.xml as needed with property placeholders.  By whatever means you come up with, have your build/deploy process spit out a properties file.  You could export the to the JAVA_OPTS shell variable, you could have your own wrapper on standalone.sh (or just modify standalone.sh) to read the properties file.  Whatever you want to do.

                1 of 1 people found this helpful