Search My Ramblings

Thursday, May 21, 2009

Communicating with ActiveMQ 5.2 from Oracle AS 10.1.3.4

First, I have to say this was a very frustrating task. This was for a customer project that requested we create a BPEL process in 10.1.3.4 that listens to a queue in Apache ActiveMQ 5.2. Naturally, I began with a Google search for someone else who's done this.

The search revealed 2 interesting posts: nabble.com, which appears to cover exactly what I need to do, and Oracle ActiveMQ JCA adapter with OC4J 10g How-to article, which is more geared for using the ActiveMQ JCA adapter from within a custom J2EE application. My preference is to set it up to use the JMS JCA adapter as a third party queueing provider rather than setting up a new resource adapter entirely, especially since I wasn't sure how to even setup a new resource adapter in OC4J outside of a custom J2EE application per the article above.

First, I tried duplicating the steps on the nabble.com site above, using 10.1.3.4 OAS with BPEL PM, and downloading the 5.2 Apache ActiveMQ. I would then get errors in the OPMN log file that it was either unable to find the org.apache.activemq.ActiveMQConnectionFactory class, it could not find the org.apache.commons.logging.LogFactory class, or it could not find the JMSAdapter JNDI entry at eis/Jms/... After trying several variations of making sure the apache.commons.logging library was included in my ActiveMQ shared library, including the version of Apache Commons Logging jar included with ActiveMQ in my shared library (OC4J didn't like 2 versions of the Commons Logging API in the classloaders, even though it just complained it couldn't find it!), and putting the ActiveMQ core jar in the j2ee/{OC4J Home}/applib folder. None of these seemed to work or prevent OC4J from complaining upon startup.

So after some communication with an Oracle contact, it seems they used the same basic steps in the nabble.com posting to connect a 10.1.3.4 instance with ActiveMQ 4.x successfully. So I tried it and it worked fine! Here's what I did:
  1. Download ActiveMQ 4.1.2 (or the latest version on this codebase, stay away from the 5.x versions!)
  2. Copy all the jar files under {ActiveMQ 4 unzip location}\lib, except the commons-logging one to your 10.1.3.4 OAS Server(s). You'll need to create a new folder to hold them and make sure the folder and its contents are created using the same user that runs your OC4J instances to avoid permissions issues.
  3. Shut down the BPEL/SOA OC4J instance running on the server where you copied the jar files above (e.g., opmnctl stop-proc process-type=oc4j_soa).
  4. Edit the {Oracle_Home}/j2ee/oc4j_soa/config/server.xml file to create a new shared library that includes the jar files copied in step 2 above. The new section should look similar to:













  5. Edit the {Oracle_Home}/j2ee/oc4j_soa/config/application.xml file to add the new shared library to the imported-shared-libraries section, as in:


  6. <imported-shared-libraries>
    <import-shared-library name="adf.oracle.domain"/>
    <import-shared-library name="apache.activemq"/>
    </imported-shared-libraries>

  7. Add a Connection Factory to the JMS JCA Adapter

  8. There are a couple of ways to do this. One way is to manually edit the {Oracle_Home}/j2ee/oc4j_soa/application-deployments/default/JmsAdapter/oc4j-ra.xml file, and another is to use Enterprise Manager to do it. To use /em, logon at http://server:port/em using the oc4jadmin login. Next select an OC4J instance containing the SOA/BPEL modules, then Applications, then default, then JmsAdapter, then Connection Factories. Click to create a new connection factory, accept the given connection factory interface class, and use the following settings:









    Property NameProperty Value
    acknowledgeModeAUTO_ACKNOWLEDGE
    connectionFactoryLocationorg.apache.activemq.ActiveMQConnectionFactory
    factoryPropertiesBrokerURL=tcp://{ActiveMQ server}:{ActiveMQ port}
    isTopic(true/false depending on whether using queue/topic)
    isTransactedtrue
    password{password of ActiveMQ user}
    username{ActiveMQ user}

  9. Create an ActiveMQ BPEL Process

No comments: