我想在我的服务器配置中指定队列的位置(队列管理器和队列名称)。
我有一个MDB只与以下人员合作;
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 {
}
}
}
在我的服务器配置中:
<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>
现在,只要我连接的队列管理器是系统上的默认队列管理器,这就可以工作。我尝试切换到不同的本地队列管理器(不是默认的),即使管理对象更新得当也不行。无论如何,我宁愿不依赖于系统范围的默认值并明确说明队列管理器。
或者,我可以设置useJNDI = false,并在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>
这很有效,而且我可以通过使用系统属性替换指定完整的激活规范选项。但是,如果我需要对jboss-ejb3.xml进行结构更改以部署到我的本地,dev,qa&amp; amp,那么很难(不可能?)使用此方案。生产环境。
如何消除jboss-ejb3.xml,并通过将standalone.xml(或domain.xml)中的节点特定项和@ActivationConfigPropery
的更多通用选项混合来提供配置?