How can I specify clientId and subscriptionName for an EJB3 message with a trusted subscription slave bean without hardcoding the values?
I have a JBoss4.2.1 server containing a JMS theme. I also have multiple terminals, each running its own JBoss with a bean driven EJB3 message that needs to subscribe to this thread using long term subscriptions. Since each subscription must specify a unique clientId and subscription name, I cannot hard-code the values in the ActivationConfigProperty annotations, and I cannot specify the values in the deployment descriptor files.
So the question is, how do you specify these values? Do I do this in JBoss config files?
Please provide complete sample configuration if possible.
Thanks.
You can do this by using a combination of entries in the ejb-jar.xml configuration file and specifying values as parameters for the JBoss launch 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">
<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 values using $ {variable} notation in the ejb-jar.xml file, they can be taken from the JBoss startup command as server parameters.
-Dclient.id = client-01 -Dsubscription.name = subscription-01