views:

806

answers:

1

I have a server running JBoss4.2.1 containing a JMS Topic. I also have multiple terminals, each running their own JBoss with an EJB3 message driven bean that need to subscribe to the topic using durable subscriptions. Since each subscription needs to specify a unique clientId and subscriptionName I can't hard code the values in the ActivationConfigProperty annotations and I can't specify the values in the deployment descriptor files.

So, the question is how do I specify these values? Do I do it in JBoss configuration files?

Please provide a complete sample configuration if possible.

Thanks.

+1  A: 

This can be done by using a combination of entries in the ejb-jar.xml configuration file and supplying the values as parameters to the JBoss startup command.

META-INF/ejb-jar.xml

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
         version="3.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"&gt;

    <enterprise-beans>

        <message-driven>
            <ejb-name>MyMsgDrivenBeanMDB</ejb-name>
            <ejb-class>com.mdb.MyMsgDrivenBeanMDB</ejb-class>
            <activation-config>
                <activation-config-property>
                    <activation-config-property-name>clientId</activation-config-property-name>
                    <activation-config-property-value>${client.id}</activation-config-property-value>
                </activation-config-property>
                <activation-config-property>
                    <activation-config-property-name>subscriptionName</activation-config-property-name>
                    <activation-config-property-value>${subscription.name}</activation-config-property-value>
                </activation-config-property>
                <activation-config-property>
                    <activation-config-property-name>reconnectInterval</activation-config-property-name>
                    <activation-config-property-value>60</activation-config-property-value>
                </activation-config-property>
            </activation-config>
        </message-driven>

    </enterprise-beans>
</ejb-jar>

By specifying the values using the ${variable} notation in the ejb-jar.xml file they can then be picked up from the JBoss start command as server options.

-Dclient.id=client-01 -Dsubscription.name=subscription-01

If you wanted to avoid adding startup parameters, you can find existing properties via the SystemProperties service in JMX. A few unique combinations that should work: ${jboss.bind.address}-${jboss.server.home.dir}, or ${java.server.rmi.codebase}
pra