I want to specify the location of a queue (queue manager & queue name) in my server configuration.
I have an MDB working with only the following;
the MDB:
@MessageDriven(name = "smis2/DelmeMDB"
, activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "java:/jms/queue/CLQ"),
@ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "true"),
@ActivationConfigProperty(propertyName = "transportType", propertyValue = "BINDINGS"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")
}
, mappedName="java:/jms/queue/A"
)
@ResourceAdapter("wmq.jmsra.rar")
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class DelmeMDB implements MessageListener {
public DelmeMDB() {
}
@Override
public synchronized void onMessage(Message message) {
String msgStr = null;
try {
if (message instanceof BytesMessage) {
BytesMessage bm = (BytesMessage) message;
byte[] buf = new byte[(int)bm.getBodyLength()];
bm.readBytes(buf);
msgStr = new String(buf, "utf8");
} else if (message instanceof TextMessage) {
TextMessage txtMsg = (TextMessage) message;
msgStr = txtMsg.getText();
} else {
throw new EJBException("Unrecognized message type");
}
if (msgStr != null) {
System.out.printf("Got a message! %s%n", msgStr);
}
} catch (Exception e) {
throw new EJBException(e);
} finally {
}
}
}
And in my server config:
<subsystem xmlns="urn:jboss:domain:resource-adapters:1.0">
<resource-adapters>
<resource-adapter>
<archive>
wmq.jmsra.rar
</archive>
<transaction-support>XATransaction</transaction-support>
<connection-definitions>
<connection-definition class-name="com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl" jndi-name="java:/WMQCF" enabled="true" use-java-context="true" pool-name="WMQCF" use-ccm="true">
<config-property name="transportType">
${pnp.mq.transportType:BINDINGS}
</config-property>
<config-property name="queueManager">
${pnp.mq.queueManager:MB8QMGR}
</config-property>
<xa-pool>
<min-pool-size>1</min-pool-size>
<max-pool-size>5</max-pool-size>
<prefill>true</prefill>
<use-strict-min>true</use-strict-min>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</xa-pool>
<validation>
<background-validation>false</background-validation>
<use-fast-fail>false</use-fast-fail>
</validation>
</connection-definition>
</connection-definitions>
<admin-objects>
<admin-object class-name="com.ibm.mq.connector.outbound.MQQueueProxy" jndi-name="java:/jms/queue/CLQ" enabled="true" use-java-context="false" pool-name="java:/jms/queue/CLQ">
<config-property name="baseQueueManagerName">
${pnp.mq.queueManager:MB8QMGR}
</config-property>
<config-property name="baseQueueName">
CLQ
</config-property>
</admin-object>
</admin-objects>
</resource-adapter>
</resource-adapters>
</subsystem>
Now this works as long as the queue manager I'm connecting to is the default queue manager on the system. I tried switching to a different local queue manager (not the default one) and it would not work even when the admin object was updated appropriately. At any rate, I'd prefer not to rely on a system-wide default and explicitly state the queue manager.
Alternatively, I can set useJNDI=false, and supply this in a jboss-ejb3.xml:
<message-driven>
<ejb-name>smis2/DelmeMDB</ejb-name>
<ejb-class>pnp.smis2.ejb.DelmeMDB</ejb-class>
<activation-config>
<activation-config-property>
<activation-config-property-name>transportType</activation-config-property-name>
<activation-config-property-value>${pnp.mq.transportType}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>queueManager</activation-config-property-name>
<activation-config-property-value>${pnp.mq.queueManager}</activation-config-property-value>
</activation-config-property>
</activation-config>
</message-driven>
</enterprise-beans>
This works well, plus I can specify the full complement of activation spec options by using system property replacement. However it is difficult (impossible?) to use this scheme if I require structural changes to the jboss-ejb3.xml to deploy to my local, dev, qa & production environments.
How can I eliminate the jboss-ejb3.xml, and provide configuration by mixing node-specific items in standalone.xml (or domain.xml) and more generic options as @ActivationConfigPropery
s ?