带有数据源的消息驱动 Bean
我的问题是如何配置 EJB 3.0 风格的消息驱动 bean 以使用 jboss 中配置的 JMS 数据源。
例如,我的 MDB 看起来像这样:
@MessageDriven(mappedName = "ExampleMDB", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "MyTopic"),
@ActivationConfigProperty(propertyName = "channel", propertyValue = "MyChannel"),
})
@ResourceAdapter(value = "wmq.jmsra.rar")
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@TransactionManagement(TransactionManagementType.BEAN)
public class MyMDB implements MessageListener {
.....
}
但我希望将 bean 附加到给定的 JMS 数据源(在 jboss 4.2.2 的情况下,位于 deploy/jms/jms-ds.xml 中)。 也许这根本不可能,但值得一问。
My question is how do I configure an EJB 3.0 style message driven bean to use a configured JMS datasource in jboss.
For example, my MDB looks something like:
@MessageDriven(mappedName = "ExampleMDB", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "MyTopic"),
@ActivationConfigProperty(propertyName = "channel", propertyValue = "MyChannel"),
})
@ResourceAdapter(value = "wmq.jmsra.rar")
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@TransactionManagement(TransactionManagementType.BEAN)
public class MyMDB implements MessageListener {
.....
}
But I would like the bean to attached to a given JMS datasource ( in the case of jboss 4.2.2 this is in deploy/jms/jms-ds.xml). Perhaps this is not even possible but is worth asking.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我正确理解您的问题,
MyMDB
侦听 WebLogic 上的主题,并且您想要使用 JBoss 提供的附加 JMS 目标,该目标在已部署的配置文件中定义并由其 JNDI 名称标识(默认情况下) ,deploy/jms/jms-ds.xml
仅包含 JMS 提供程序和连接工厂的配置 - 无数据源)。最简单的方法是让容器通过其 JNDI 名称注入 JMS 目标和连接工厂(在 JBoss 中,JMS 目标由 部署 xxx-service.xml 文件)。 启动时,您可以初始化连接,并在 MDB 释放后立即执行清理。
以下示例显示了注入(
@Resource
)和资源管理(@PostConstruct
和@PreDestroy
)。 JMS 连接和目标在useJmsDestination(String)
中使用来发送文本消息。我希望这可以帮助你。
If I understood your problem correctly,
MyMDB
listens to a topic on WebLogic, and you want to use an additional JMS destination provided by JBoss, defined in a deployed configuration file and identified by its JNDI name (by default,deploy/jms/jms-ds.xml
only contains the configuration for the JMS provider and connection factories -- no data sources).The easiest way is to let the container inject the JMS destination and a connection factory via its JNDI name (in JBoss the JMS destinations are configured by deploying xxx-service.xml files). On startup you can then initialize the connection, and perform cleanup as soon as the MDB is released.
The following examples shows injection (
@Resource
) and resource managemend (@PostConstruct
and@PreDestroy
). The JMS connection and destination is used inuseJmsDestination(String)
to send a text message.I hope this can help you.
我认为您要问的是“如何指定用于 MDB 的 JMS 数据源的 JNDI 位置?”
在这种情况下,答案是:
此外,请查看以下页面,其中提供了有关在 jBoss 中配置 MDB 的大量有用详细信息:
http://www.jboss.org/community/docs/DOC-9352
I think what you are asking is "How do I specify the JNDI location of the JMS datasource to use for an MDB?"
In which case the answer is:
Also, take a look at the following page which provides loads of useful details on configuring MDBs in jBoss:
http://www.jboss.org/community/docs/DOC-9352