在 Wildfly 10 中,是否可以在 standalone-full.xml 中指定 MDB 查找属性,而不是在编译时在 Java 源代码中绑定?
In Wildfly 10, can the MDB lookup properties be specified in the standalone-full.xml rather than be bound at compile time in the Java source code?
在 Wildfly 10 中,我想将 MDB 的一些注释移动到关联的资源适配器。
根据Connect a pooled-connection-factory to a Remote Artemis Server
可以按如下方式注释 MDB(从参考页面复制到此处):
@ResourceAdapter("remote-artemis")
@MessageDriven(name = "MyMDB", activationConfig = {
@ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "myQueue"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")
})
public class MyMDB implements MessageListener {
//
}
有什么方法可以将查找决定从编译时间推迟到调用时间吗?我想在我的 standalone-full.xml
中指定属性 "useJNDI" 和 "destination" 的值
我尝试按如下方式注释 MDB:
@ResourceAdapter("my-remote")
@MessageDriven(name = "MyMDB", activationConfig = {
//try specifying the next 2 properties in the configuration file
//@ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"),
//@ActivationConfigProperty(propertyName = "destination", propertyValue = "myQueue"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")
})
public class MyMDB implements MessageListener {
//
}
然后在standalone-full.xml中配置"my-remote"如下:
<pooled-connection-factory name="my-remote" entries="jms/RemoteCF"
connectors="batch-connector" consumer-window-size="0"
useJNDI="false" destination="myQueue"
user="user" password="password" />
但是收到以下错误信息:
Message: WFLYCTL0376: Unexpected attribute 'useJNDI' encountered. Valid attributes are: 'entries, discovery-group, connectors, ha, client-failure-check-period, connection-ttl, call-timeout, call-failover-timeout, consumer-window-size, consumer-max-rate, confirmation-window-size, producer-window-size, producer-max-rate, protocol-manager-factory, compress-large-messages, cache-large-message-client, min-large-message-size, client-id, dups-ok-batch-size, transaction-batch-size, block-on-acknowledge, block-on-non-durable-send, block-on-durable-send, auto-group, pre-acknowledge, retry-interval, retry-interval-multiplier, max-retry-interval, reconnect-attempts, failover-on-initial-connection, connection-load-balancing-policy-class-name, use-global-pools, scheduled-thread-pool-max-size, thread-pool-max-size, group-id, transaction, user, password, min-pool-size, use-auto-recovery, max-pool-size, managed-connection-pool, enlistment-trace, initial-message-packet-size, initial-connect-attempts'
是否必须在编译时指定查找属性?
如果我需要一个 Wildfly 实例使用 jndi 进行查找,而另一个使用非 JNDI 名称进行查找,我真的必须创建两个 MDB,只是注释略有不同吗?
实际上只是 HornetQ JCA 资源适配器之上的一个门面,以方便配置。除了 元素中标识的一组有限的配置属性(有关更多详细信息,请参阅模式),所有配置属性仅适用于出站适配器(即它们不适用于使用入站适配器的 MDB ). MDB 使用的入站适配器实际上是用注释或部署描述符(即 ejb-jar.xml)来配置的。
要实现您想要的效果,您可以将配置外部化到部署描述符中,或者您可以在注释中使用系统 属性 替换。为了实施后者,您需要:
- 在您的服务器配置中将
设置为 true
- 在您的服务器配置中将
设置为 true
在注释中使用 ${} 语法,例如:
@ActivationConfigProperty(propertyName = "destination", propertyValue = "${myDestinationProperty}")
在服务器配置中定义相应的系统属性,例如:
<system-properties>
<property name="myDestinationProperty" value="myQueue"/>
</system-properties>
明确地说,在编译时没有对注释进行任何处理。当 MDB 被激活时,它们都是在部署时读取的。
在 Wildfly 10 中,我想将 MDB 的一些注释移动到关联的资源适配器。
根据Connect a pooled-connection-factory to a Remote Artemis Server 可以按如下方式注释 MDB(从参考页面复制到此处):
@ResourceAdapter("remote-artemis")
@MessageDriven(name = "MyMDB", activationConfig = {
@ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "myQueue"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")
})
public class MyMDB implements MessageListener {
//
}
有什么方法可以将查找决定从编译时间推迟到调用时间吗?我想在我的 standalone-full.xml
中指定属性 "useJNDI" 和 "destination" 的值我尝试按如下方式注释 MDB:
@ResourceAdapter("my-remote")
@MessageDriven(name = "MyMDB", activationConfig = {
//try specifying the next 2 properties in the configuration file
//@ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"),
//@ActivationConfigProperty(propertyName = "destination", propertyValue = "myQueue"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")
})
public class MyMDB implements MessageListener {
//
}
然后在standalone-full.xml中配置"my-remote"如下:
<pooled-connection-factory name="my-remote" entries="jms/RemoteCF"
connectors="batch-connector" consumer-window-size="0"
useJNDI="false" destination="myQueue"
user="user" password="password" />
但是收到以下错误信息:
Message: WFLYCTL0376: Unexpected attribute 'useJNDI' encountered. Valid attributes are: 'entries, discovery-group, connectors, ha, client-failure-check-period, connection-ttl, call-timeout, call-failover-timeout, consumer-window-size, consumer-max-rate, confirmation-window-size, producer-window-size, producer-max-rate, protocol-manager-factory, compress-large-messages, cache-large-message-client, min-large-message-size, client-id, dups-ok-batch-size, transaction-batch-size, block-on-acknowledge, block-on-non-durable-send, block-on-durable-send, auto-group, pre-acknowledge, retry-interval, retry-interval-multiplier, max-retry-interval, reconnect-attempts, failover-on-initial-connection, connection-load-balancing-policy-class-name, use-global-pools, scheduled-thread-pool-max-size, thread-pool-max-size, group-id, transaction, user, password, min-pool-size, use-auto-recovery, max-pool-size, managed-connection-pool, enlistment-trace, initial-message-packet-size, initial-connect-attempts'
是否必须在编译时指定查找属性?
如果我需要一个 Wildfly 实例使用 jndi 进行查找,而另一个使用非 JNDI 名称进行查找,我真的必须创建两个 MDB,只是注释略有不同吗?
要实现您想要的效果,您可以将配置外部化到部署描述符中,或者您可以在注释中使用系统 属性 替换。为了实施后者,您需要:
- 在您的服务器配置中将
设置为 true - 在您的服务器配置中将
设置为 true 在注释中使用 ${} 语法,例如:
@ActivationConfigProperty(propertyName = "destination", propertyValue = "${myDestinationProperty}")
在服务器配置中定义相应的系统属性,例如:
<system-properties> <property name="myDestinationProperty" value="myQueue"/> </system-properties>
明确地说,在编译时没有对注释进行任何处理。当 MDB 被激活时,它们都是在部署时读取的。