5 Replies Latest reply on Jan 9, 2012 2:28 AM by fcosfc

    Connect to Oracle AQ?

    Pasi Kovanen Newbie
      If someone has successfully connected HornetQ to Oracle AQ queue, I would really appreciate to see the configuration of HornetQ.
        • 1. Re: Connect to Oracle AQ?
          Tim Fox Master

          Can you explain what you mean by "connected HornetQ to Oracle AQ queue" in more detail?

           

          I don't really understand the question.

          • 2. Re: Connect to Oracle AQ?
            Pasi Kovanen Newbie
            We are using Oracle AQ, and we would like HornetQ to consume messages from AQ. Ultimate goal would be to use JBoss AS with HornetQ and connect EJB3 MDB's to AQ with HornetQ.
            • 3. Re: Connect to Oracle AQ?
              Tim Fox Master

              This is not possible with more or less any enterprise messaging system.

               

              Each messaging system has it's own underlying protocol which are not compatible between systems.

               

              A HornetQ client connects to a HornetQ server.

              A Weblogic JMS client connects to a Weblogic JMS server

              A Oracle AQ client connects to a Oracle server

              etc

               

              It's not possible for a client from one system to connect to another since they won't understand the protocol.

               

              (This is being addresses to some extent with AMQP, but that is still emerging)

               

              Perhaps what you really want to do is *bridge* messages from AQ to HornetQ?

               

              This means you use a Oracle AQ client to consume messages from Oracle AQ, then you take that message and sent it to HornetQ.

               

              At no point does a HornetQ client talk to a Oracle AQ server or an Oracle AQ client talk to a HornetQ server.

               

              This should be possible using a JMS bridge- assuming Oracle AQ implements the JMS 1.1 specification properly. Although I haven't tried it with AQ

               

              See the user manual for more details.

              • 4. Re: Connect to Oracle AQ?
                Pasi Kovanen Newbie
                Thanks for correcting my terminology. JMS Bridge is exactly what I'm looking for. I'd love to hear if someone has successfully used it with AQ. With the help of oracle.jms.AQjmsFactory it should be doable.
                • 5. Re: Connect to Oracle AQ?
                  fcosfc Newbie

                  Hi Pasi and Tim,

                   

                     I struggled with this issue some time ago. Implementing the bridge is possible because Oracle Advanced Queuing is JMS 1.1 compliant but I found some problems.

                   

                     The first task is to register your Oracle AQ queues, topics and connection factories in a LDAP server and lookup them using a JNDI connection. The obvious option is to use Oracle Internet Directory (OID), although using OpenLDAP is also possible, please visit these posts of Edwin Biemond's blog about how to do it: Using OpenLDAP for net8 and AQ connection factory and Lookup Oracle database queue (AQ) with jndi and LDAP.

                   

                     I setup the bridge between a HornetQ 2.2.5 standalone installation and an Oracle 11.2 database, it ran properly with a DUPLICATES_OK quality of service, but when I tried to move to an ONCE_AND_ONLY_ONCE one, which requires XA, I got an NullPointerException:

                   

                  oracle.jms.AQjmsException: Error creating the db_connection

                  at oracle.jms.AQjmsDBConnMgr.getConnection

                  at oracle.jms.AQjmsDBConnMgr.<init>

                  at oracle.jms.AQjmsXAConnection.<init>

                  at oracle.jms.AQjmsXAQueueConnectionFactory.createAllXAConnection

                  at oracle.jms.AQjmsXAQueueConnectionFactory.createXAQueueConnection

                   

                     After a research on Oracle Support notes, I found that the Oracle API  has a bug (10102373) that it will be fixed on the future release 12.1 In my case, a bridge from HornetQ to Oracle AQ, I found a workaround: to save the JMS Message ID in a Oracle table and implement a unique index on that column, you have to take into account that the JMS Messege ID sent by HornetQ is a property that can be recovered with the method get_string_property of the Oracle type aq$_jms_message. Here you are an excerpt of my hornetq-beans.xml file:

                   

                       <bean name="JMSBridge" class="org.hornetq.jms.bridge.impl.JMSBridgeImpl">

                                  <constructor>

                                      ...

                                           <!-- concatenate JMS messageID to the target's message header -->

                                           <parameter>true</parameter>

                         ...

                            </bean>

                       ...    

                       <!-- TargetCFF describes the ConnectionFactory used to connect to the target destination -->

                            <bean name="TargetCFF" class="org.hornetq.jms.bridge.impl.JNDIConnectionFactoryFactory">

                                     <constructor>

                                              <parameter>

                                                       <inject bean="TargetJNDI" />

                                              </parameter>

                                              <parameter>cn=test,cn=oracledbconnections,cn=DES,cn=OracleContext,ou=Services,dc=fcosfc,dc=es</parameter>

                                     </constructor>

                            </bean>

                       ...   

                       <!-- TargetDestinationFactory describes the Destination used as the target -->

                            <bean name="TargetDestinationFactory" class="org.hornetq.jms.bridge.impl.JNDIDestinationFactory">

                                     <constructor>

                                              <parameter>

                                                       <inject bean="TargetJNDI" />

                                              </parameter>

                                              <parameter>cn=test.hornetq_q,cn=OracleDBQueues,cn=DES,cn=OracleContext,ou=Services,dc=fcosfc,dc=es</parameter>

                                     </constructor>

                            </bean>

                       ...   

                       <!-- JNDI is a Hashtable containing the JNDI properties required -->

                           <!-- to connect to the *target* JMS resources                    -->

                           <bean name="TargetJNDI" class="java.util.Hashtable">

                                   <constructor class="java.util.Map">

                                           <map class="java.util.Hashtable" keyClass="java.lang.String"

                                                                                     valueClass="java.lang.String">

                                                   <entry>

                                                           <key>java.naming.factory.initial</key>

                                                           <value>com.sun.jndi.ldap.LdapCtxFactory</value>

                                                   </entry>

                                                   <entry>

                                                           <key>java.naming.provider.url</key>

                                                           <value>ldap://localhost:389</value>

                                                   </entry>

                                                   <entry>

                                                           <key>server_dn</key>

                                                           <value>dc=fcosfc,dc=es</value>

                                                   </entry>

                                                   <entry>

                                                           <key>java.naming.security.authentication</key>

                                                           <value>simple</value>

                                      </entry>

                                                   <entry>

                                                           <key>java.naming.security.principal</key>

                                                           <value>cn=Manager,dc=fcosfc,dc=es</value>

                                                   </entry>

                                                   <entry>

                                                           <key>java.naming.security.credentials</key>

                                                           <value>secret</value>

                                                   </entry>

                                          </map>

                                  </constructor>

                           </bean>

                   

                     I also tried to setup the bridge using HornetQ deployed as the JMS provider of JBoss 6.0.0, but in this case it was unsuccessful, I didn't get any error but the messages never arrived to Oracle AQ. I reviewed all the logs of both JBoss and Oracle, but I couldn't find out the cause.

                   

                  Best regards,

                   

                  Paco Saucedo.