サーバー構成でキューの場所 (キュー マネージャーとキュー名) を指定したいと考えています。
次のものだけで動作する 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 に構造的な変更を加えてローカル、開発、QA、本番環境にデプロイする必要がある場合、このスキームを使用するのは困難 (不可能?) です。
jboss-ejb3.xml を削除し、standalone.xml (または domain.xml) のノード固有の項目と@ActivationConfigPropery
s としてのより一般的なオプションを混合して構成を提供するにはどうすればよいですか?