How to pass parameters through the deployment descriptor to MDB ?
gagagogo Aug 14, 2014 3:37 AMGood day!
I have a wildfly-8.1.0.CR1, mdb like this:
public class PBX implements MessageListener
{
@Resource(name="host")
private String host;
@Resource(name="port")
private String port;
@Resource(name="login")
private String login;
@Resource(name="password")
private String password;
@Override
public void onMessage(Message message) {
try {
System.out.println(((TextMessage)message).getText());
} catch (JMSException e) {
e.printStackTrace();
}
}
}
and also, deployment descriptor ejb-jar.xml:
<?xml version="1.0" encoding="UTF-8"?> <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" 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" version="3.0"> <enterprise-beans> <message-driven> <ejb-name>PBXE1</ejb-name> <ejb-class>org.test.PBX</ejb-class> <activation-config> <activation-config-property> <activation-config-property-name>destination</activation-config-property-name> <activation-config-property-value>queues.test.PBX1</activation-config-property-value> </activation-config-property> <activation-config-property> <activation-config-property-name>destinationType</activation-config-property-name> <activation-config-property-value>javax.jms.Queue</activation-config-property-value> </activation-config-property> <activation-config-property> <activation-config-property-name>acknowledgeMode</activation-config-property-name> <activation-config-property-value>Auto-acknowledge</activation-config-property-value> </activation-config-property> </activation-config> <env-entry> <env-entry-name>host</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>127.0.0.1</env-entry-value> </env-entry> <env-entry> <env-entry-name>port</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>22</env-entry-value> </env-entry> <env-entry> <env-entry-name>login</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>user</env-entry-value> </env-entry> <env-entry> <env-entry-name>password</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>pass</env-entry-value> </env-entry> </message-driven> </enterprise-beans> </ejb-jar>
And it works. Now I want to add one more instance of this class that listens to another queue, and give him the other connection settings. But only works without the setting <env-entry> twice. Can i pass different values of env-entry for evry instance ?