是否可以将 Wildfly 与 RabbitMQ (amqp) 连接起来? [英] Is it posible to connect wildfly with RabbitMQ (amqp)?

查看:59
本文介绍了是否可以将 Wildfly 与 RabbitMQ (amqp) 连接起来?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在进行概念验证,但无法收听来自 Wildfly 的消息.有谁知道这可能吗?我已经尝试了很多天:C

I'm working in a proof of concept and I'm not able to listen messages from wildfly. Does anyone knows is this is possible? I have been trying for a lot of days :C

推荐答案

你可以使用 RabbitMQ JMS在 Wildfly 上运行的应用程序中的客户端.

您只需要使用 CDI 生成器(如果您的应用程序是 JEE)手动生成 RabbitMQ JMS ConnectionFactory 和 Destination 对象,或者通过 RabbitMQ JMS 客户端 1.7.0 版本的 JNDI 绑定配置.

You just have to produce a the RabbitMQ JMS ConnectionFactory and Destination objects, manually with a CDI producer (if your app is JEE), or via JNDI bindings configuration as of 1.7.0 version of RabbitMQ JMS Client.

对于 Wildfly JNDI 绑定配置,您可以查看 RabbitMQ JMS 客户端 文档和 Wildfly 命名子系统配置.

For Wildfly JNDI bindings configuration you can take a look at RabbitMQ JMS Client documentation and at Wildfly Naming Subsystem configuration.

然后您可以在您的应用程序中使用 @Resource 注入 JMS Connection Factory 和 Destination 对象.请注意,您还必须将 JMS 客户端库放在 Wildfly 全局模块

Then you could inject the JMS Connection Factory and Destination objects with @Resource in your app. Note that you have to put also the JMS client lib in a jboss-module declared in Wildfly global-modules

最后,如果您想注册消息侦听器,您可以尝试手动完成,方法是创建实现 JMS MessageListener 接口的侦听器并在 setMessageListener 方法(加上 CDI 管道).实际上,现在不可能在当前版本的 RabbitMQ JMS 客户端中使用消息驱动 Bean.有关详细信息,请参阅这篇文章.但是,我不确定这最后一个在 Wildfly 中是否有效(有待测试),根据 javadoc,此方法会引发 JMS 异常:

Finally if you want to register message listeners, you could try to do that manually, by creating listeners implementing JMS MessageListener interface and registering listeners manually to RabbitMQ queues with the help of setMessageListener method (plus CDI plumbing). Indeed, it is not possible for now to use Message Driven Beans with the current version RabbitMQ JMS Client. See this post for details. However I am not sure whether this last one would work or not in Wildfly (to be tested), as per the javadoc this method throws a JMS exception:

如果 JMS 提供者由于以下原因之一未能设置 MessageConsumer 的 MessageListener:发生内部错误或在 Java EE Web 或 EJB 应用程序中调用了此方法(尽管不能保证抛出异常在这种情况下)

if the JMS provider fails to set the MessageConsumer's MessageListener for one of the following reasons: an internal error has occurred or this method has been called in a Java EE web or EJB application (though it is not guaranteed that an exception is thrown in this case)

另外,也许这对从 WEB 配置文件而不是 Java EE 7 完整配置文件开始的 Wildfly 最有效?

Also, maybe this would work best with Wildfly started with the WEB profile, not the Java EE 7 Full Profile ?

这篇关于是否可以将 Wildfly 与 RabbitMQ (amqp) 连接起来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆