Is it posible to connect wildfly with RabbitMQ (amqp)?

雨燕双飞 提交于 2019-12-24 01:13:21

问题


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


回答1:


You could use RabbitMQ JMS Client in your application running on Wildfly.

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.

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

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

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:

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)

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



来源:https://stackoverflow.com/questions/42979143/is-it-posible-to-connect-wildfly-with-rabbitmq-amqp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!