How to connect to RabbitMQ using RabbitMQ JMS client from an existing JMS application?

后端 未结 3 1948
我在风中等你
我在风中等你 2021-02-06 10:57

I have a generic standalone JMS application which works with following JMS providers WebSphere, HornetQ and ActiveMq. I pass Context.INITIAL_CONTEXT_FACTORY and Context.PROVIDER

3条回答
  •  没有蜡笔的小新
    2021-02-06 11:15

    For people who are hitting this exception

    Caused by: javax.naming.NamingException: Unknown class [com.rabbitmq.jms.admin.RMQConnectionFactory]
    

    even after following @Ualter Jr.'s answer is because of incorrect entries in the .bindings file.

    I corrected the following 2 lines in .bindings file

    ConnectionFactory/ClassName=com.rabbitmq.jms.admin.RMQConnectionFactory --->
    ConnectionFactory/ClassName=javax.jms.ConnectionFactory
    

    and

    YourQueueName/ClassName=com.rabbitmq.jms.admin.RMQDestination --->
    StriimQueue/ClassName=javax.jms.Queue
    

    When I hit this exception again I just opened this class and found that it expects the following classnames

          /*
         * Valid class names are:
         * javax.jms.ConnectionFactory
         * javax.jms.QueueConnectionFactory
         * javax.jms.TopicConnectionFactory
         * javax.jms.Topic
         * javax.jms.Queue
         *
         */
    

    Correcting these entries would enable existing/new JMS applications to work with RabbitMQ.

提交回复
热议问题