我在尝试让我们的 MDB 在不同环境中使用动态加载的属性时遇到了一些困难。
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "providerURL", propertyValue = "localhost:7001"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue ="javax.jms.Queue") }, mappedName = "jms.MyQueue", name = "MyQueueReader")
public class QueueReaderBean implements MessageListener {
}
我们想在部署到不同环境时更改 providerURL。你有什么建议吗?
我们不想使用 ejb.xml,而是在构造函数或后构造方法中以编程方式使用它。
谢谢
最佳答案
也许与此条目有关connecting to a remote JMS provider from a Message Driven Bean (MDB)
并使用 jnp 协议(protocol)的 url 可以完成这项工作:
@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "providerURL", propertyValue = "jnp://hostname:1099"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue") }, mappedName = "jms.MyQueue", name = "MyQueueReader") 公共(public)类 QueueReaderBean 实现 MessageListener {
关于java - 动态设置 MessageDrivenBeans 中的激活配置属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13760190/