12 Replies Latest reply on Aug 3, 2011 7:55 AM by Marc B

    Configure Hornetq to connect to Websphere MQ

    Marc B Newbie

      Hi,

       

      I'm new to JMS and HornetQ and have some question about configuring HornetQ.

      I want to send messages to a Websphere MQ und use a standalone HornetQ server.

       

      Therefore I followed the EmbeddedSimple-Example in the jms-examples-folder.

      My problem is now how to set up the hornetq-configuration.xml and hornetq-jms.xml.

       

      I've read several posts on JBoss and Websphere, where the wmq.jmsra.rar is used in the configuration. But I don't know how to translate that for my simple example.

      I copied the jars from the rar-file to my buildpath to use the connectionFactory.

       

      My hornetq-configuration.xml contains the following:

       

      <connectors>
          <connector name="MQC" >
                   <factory-class>com.ibm.mq.jms.MQQueueConnectionFactory</factory-class>
                   <param key="channel" value="CHANNEL1" />
                   <param key="hostName" value="MQS.MYSERVER.DE" />
                   <param key="port" value="1415" />
                   <param key="queueManager" value="CSQT" />
                   <param key="transportType" value="CLIENT" />             
               </connector>
          </connectors>
      

      the hornetq-jms.xml

       

      <connection-factory name="MQF">
              <connectors>
                  <connector-ref connector-name="MQC"/>            
              </connectors>
              <entries>
                  <entry name="MQF"/>
              </entries> 
          </connection-factory>
      
          <queue name="LOCAL.QUEST01.T.QUEUE">
              <entry name="MQSQueue"/>
          </queue>
      

       

      The Example is very simple:

       

      EmbeddedJMS jmsServer = new EmbeddedJMS();
                   jmsServer.start();
      
                   ConnectionFactory cf = (ConnectionFactory)jmsServer.lookup("MQF");
                   Queue queue = (Queue)jmsServer.lookup("MQSQueue");
                   
      
                   // Step 10. Send and receive a message using JMS API
                   Connection connection = null;
                   try
                   {
                      connection = cf.createConnection();
                      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                      MessageProducer producer = session.createProducer(queue);
                      TextMessage message = session.createTextMessage("Hello sent at " + new Date());
                      
                      ...
                      }
                      ...
      

      When running the example a ConnectionFactory and Queue is set from the configuration, but when creating a Connection on the connectionfactory, a classCastException appers (com.ibm.mq.jms.MQQueueConnectionFactory cannot be cast to org.hornetq.spi.core.remoting.ConnectorFactory).

       

       

      I hope someone has done something like this before and can give me a hint how to configure the connector.

       

      Greetings

      Marc

        • 1. Re: Configure Hornetq to connect to Websphere MQ
          Andy Taylor Master

          I'm not really sure what youu are trying to acheive, are you trying to create a bridge from a Websphere MQ server to a Hornetq Server? if so you need a JMS bridge

          • 2. Re: Configure Hornetq to connect to Websphere MQ
            Marc B Newbie

            I'm trying to run a standalone hornetq-server and create and send messages to a Websphre MQ.

             

            The Embedded-Example in the sample-files just makes the starting and stopping of my hornetq-server direct in java-code instead of running a start/stop-script.

            • 3. Re: Configure Hornetq to connect to Websphere MQ
              Andy Taylor Master

              I'm trying to run a standalone hornetq-server and create and send messages to a Websphre MQ.

              That makes no sense,  where are you sending the messages from and where are they going too.

               

              The Embedded-Example in the sample-files just makes the starting and stopping of my hornetq-server direct in java-code instead of running a start/stop-script.

              thats exactly what the example is there to show.

               

              i dont really understand what you want

              • 4. Re: Configure Hornetq to connect to Websphere MQ
                Marc B Newbie

                I'm sorry that I can't explain it any better.

                I'm just trying to change the example, so that it is not sending a message to the queue, that is defined at my own local hornetq-server, but to a queue in a websphere.

                The queue on this websphere exists already in my company, I know the hostname, queuename etc., but don't know how to change the hornetq-configuration.xml so that the message goes to this websphere-queue.

                 

                Hope you understand what I'm trying to do.

                • 5. Re: Configure Hornetq to connect to Websphere MQ
                  Andy Taylor Master

                  what do u need hornetq for at all, just write yourclient to use Websphere

                  • 6. Re: Configure Hornetq to connect to Websphere MQ
                    Marc B Newbie

                    I think we're missunderstanding eachother.

                    The application where I want to send messages from doesn't run on websphere.

                     

                    I develop an application that shall run on a tomcat-server, where no websphere mq is available and have to talk to an other websphere mq server.

                    So my application shall use hornetq because there is no other JMS on my server.

                    • 7. Re: Configure Hornetq to connect to Websphere MQ
                      Clebert Suconic Master

                      The connectors and acceptors on hornetq-configuration.xml are related to hornetq only.

                       

                       

                      We won't understand a com.ibm.mq.jms.MQQueueConnectionFactory, as it doesn't implement our internal connector.

                       

                       

                      Please, read our connector and acceptors documentation. (Well.. read the docs anyway).

                       

                       

                      This is to chose between a Netty and InVM Protocol (Protocols for Hornetq).

                       

                       

                      The closest you have on HornetQ is to create a JMS bridge between HornetQ and ActiveMQ, but you can't send messages to MQSeries using HornetQ's libraries. (that's silly actually).

                       

                       

                      If you want to talk to MQSeries, use MQSeries API. That's simple!

                       

                       

                      if you want to bridge a destination on HornetQ.. that's something different.

                      • 8. Re: Configure Hornetq to connect to Websphere MQ
                        Marc B Newbie

                        Oh, I've understood the connectors in the way, that they are used to connect a client to server (as chapter 16 says), no matter what mq-implementation is running on that server (activeq, mqseries, hornetq).

                        That's why I tried to define the connector for the mqseries-server, so my client can create a message and use this connector to send it to mqseries-server.

                         

                        The JMS-Bridge in chapter 33, I thought, is used to receive messages from one server, and deliver it forward to another server. But that's not what I wanted to do.

                        Or did I missunderstood the bridge-concept, and can use it to create a message at my client and send it to a server I defined with the bridge?

                        • 9. Re: Configure Hornetq to connect to Websphere MQ
                          Andy Taylor Master

                          Oh, I've understood the connectors in the way, that they are used to connect a client to server (as chapter 16 says), no matter what mq-implementation is running on that server (activeq, mqseries, hornetq).

                          That's why I tried to define the connector for the mqseries-server, so my client can create a message and use this connector to send it to mqseries-server.

                          A connector is a definition of how a client connects to a hornetq server, not another vendors server. If you want to connect to another messaging system you have to use their client not hornetq.

                           

                          To be honest i still don't understand what you are trying to do, if you just want a component in the tomcat server to send/receive a message to/from a messaging system then just use normal jms and nake sure that the correct client libs are available.

                          • 10. Re: Configure Hornetq to connect to Websphere MQ
                            Marc B Newbie

                            if you just want a component in the tomcat server to send/receive a message to/from a messaging system then just use normal jms and nake sure that the correct client libs are available.

                            Yes, you got it.

                            I just want to send a message from my Tomcat-Server to another server-mq running with MQ-Series.

                            And instead of using a Websphere-MQ on Tomcat, I thought Hornetq could be used instead, because "HornetQ provides a fully compliant JMS 1.1 API".

                             

                            Please correct me if I'm wrong and can't do that with HornetQ, and have to do it with Websphere-MQ on Tomcat instead.

                            • 11. Re: Configure Hornetq to connect to Websphere MQ
                              Andy Taylor Master

                              I think your misunderstanding how meesaging servers work, they aren't interoperable. You have to use the HornetQ client to connect to a HornetQ server and the same with MQ or any other jms vendor

                              • 12. Re: Configure Hornetq to connect to Websphere MQ
                                Marc B Newbie

                                Thank you. I really understood it wrong.

                                I thought I can use any messaging server to send messages to any other vendors messaging server, if they were just configuerd correct.

                                 

                                Well, I'll search an other way to send my message to websphere-mq.