Discussion:
[jboss-user] [Beginner's Corner] - Externalizing resource adapter configs from standalone.xml in Jboss-as 7.1.1
nav
2013-05-29 23:50:25 UTC
Permalink
nav [https://community.jboss.org/people/nav] created the discussion

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

To view the discussion, visit: https://community.jboss.org/message/820238#820238

--------------------------------------------------------------
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!
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/820238#820238]

Start a new discussion in Beginner's Corner at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]
nav
2013-05-30 22:28:57 UTC
Permalink
nav [https://community.jboss.org/people/nav] created the discussion

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

To view the discussion, visit: https://community.jboss.org/message/820534#820534

--------------------------------------------------------------
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.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/820534#820534]

Start a new discussion in Beginner's Corner at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]
Doug Grove
2013-06-26 21:35:48 UTC
Permalink
Doug Grove [https://community.jboss.org/people/dgrove_redhat.com] created the discussion

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

To view the discussion, visit: https://community.jboss.org/message/825105#825105

--------------------------------------------------------------
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
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/825105#825105]

Start a new discussion in Beginner's Corner at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]
nav
2013-06-27 00:49:41 UTC
Permalink
nav [https://community.jboss.org/people/nav] created the discussion

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

To view the discussion, visit: https://community.jboss.org/message/825130#825130

--------------------------------------------------------------
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
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/825130#825130]

Start a new discussion in Beginner's Corner at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]
Doug Grove
2013-06-27 12:34:56 UTC
Permalink
Doug Grove [https://community.jboss.org/people/dgrove_redhat.com] created the discussion

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

To view the discussion, visit: https://community.jboss.org/message/825241#825241

--------------------------------------------------------------
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.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/825241#825241]

Start a new discussion in Beginner's Corner at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]
Loading...