OpenEJB:使用自定义 ConnectionFactory 配置 MDB
如 OpenEJB 文档中所述,我们可以配置 JMS 连接工厂和队列,它们将在 JNDI 中显示为:
openejb:Resource/MyJmsConnectionFactory,
openejb:Resource/MyQueue
给定这些 JNDI 条目,我如何告诉 MDB 使用它们?
是否可以更改 JNDI 名称,例如 ConnectionFactory 显示为
java:/ConnectionFactory
或ConnectionFactory
As described in OpenEJB docs, we can configure JMS connection factory and queues, and they will appear in JNDI as:
openejb:Resource/MyJmsConnectionFactory,
openejb:Resource/MyQueue
Given those JNDI entries, how can I tell to MDB to use them?
Is it possible to change JNDI name, for example ConnectionFactory to appear as
java:/ConnectionFactory
orConnectionFactory
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事情的运作方式可能与你想象的不同。指定 MDB 与 javax.jms.Queue 绑定,并且该队列的名称是 EJB 规范的一部分并通过 ActivationConfig 完成,如下所示:
MDB 容器本身实际上根本不支持 JMS。它只是理解应该将 bean 连接到特定的资源适配器。
上面显示了一个连接到通过 ActiveMQ 使用 JMS 的资源适配器的 MDB 容器。
下面是一个示例,显示 MDB 容器连接到 Quartz 资源适配器
不可能按照规范告诉 MDB 容器 JMS 特定的事情,这种关系比这更通用。这篇博客文章提供了一些见解:事情如何运作。
Things work differently than you may be imagining. Specifying that an MDB is tied to a javax.jms.Queue and the name of that queue is part of the EJB specification and done via the ActivationConfig, like so:
The MDB container itself is not actually JMS-aware at all. It simply understands that it should hook the bean up to a specific Resource Adapter.
The above shows an MDB Container hooked up to a Resource Adapter that uses JMS via ActiveMQ.
Here is an example that shows an MDB Container hooked up to a Quartz Resource Adapter
It isn't possible to tell the MDB Container about JMS specific things as per specification, the relationship is much more generic than that. This blog post gives some insight as to how things work.