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
-
Hi Cesar, have you found another solution to listen to RabbitMQ destination from Wildfly? – Rémi Bantos Aug 28 '17 at 15:26
1 Answers
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 ?

- 1,899
- 14
- 27