Oracle Advanced Queueing (AQ) is the Oracle database's queue management feature. AQ provides a message queuing infrastructure as integral part of the Oracle server engine. It provides an API for enqueing messages to database queues. These messages can later be dequeued for asynchronous processing.
In short Oracle AQ provides most of the functionalities which standard Message Queue (MQ) like ActiveMQ, RabbitMQ, etc. provides. But Oracle AQ is not widely used as MQ infrastructure and not very straight forward to integrate (at least I found very less documentation).
In this blog post I am explaining the basic steps to integrate Oracle AQ with Apache Camel, popular routing and mediation framework which implements Enterprise Integration Patterns. I am using Camel version 2.15.2, Spring 4.2.0 RELEASE with JDK 7. I am assuming you are aware of basics of Spring Camel integration and usage of Camel JMS component.
Below is how my camel-context.xml looks like
xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<camelContext id="camelContext" errorHandlerRef="defaultErrorHandler" xmlns="http://camel.apache.org/schema/spring" >
<package>com.abc.xyz.route</package>
</camelContext>
<bean id="connectionFactoryOracleAQQueue" class="oracle.jms.AQjmsFactory" factory-method="getQueueConnectionFactory">
<constructor-arg index="0"> <value>jdbc:oracle:thin:@(DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=host.org.com) (PORT=1521)) (CONNECT_DATA= (SID=test)))</value> </constructor-arg> <constructor-arg index="1" type="java.util.Properties"> <value></value> </constructor-arg> </bean> <bean id="oracleQueueCredentials" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter"> <property name="targetConnectionFactory"> <ref bean="connectionFactoryOracleAQQueue" /> </property> <property name="username"> <value>test</value> </property> <property name="password"> <value>test</value> </property> </bean> <bean id="oracleQueue" class="org.apache.camel.component.jms.JmsComponent"> <property name="connectionFactory" ref="oracleQueueCredentials" /> </bean> </beans>
And this is how my route looks like
from("oracleQueue:TEST_Q") .routeId("AQSample") .log(LoggingLevel.INFO, "Processing message: ${body}") .processRef("myProcessor")
.end();
This looks simple enough... right? But when I tried to run this I started to get a lot of issue. The most prominent was
DefaultMessageListenerContainer-1
java.lang.AbstractMethodError: oracle.jms.AQjmsQueueConnectionFactory.createConnection(Ljava/lang/String;Ljava/lang/String;)Ljavax/jms/Connection;
Finally I got around this issue by adding proper version of aqapi13.jar and ojdbc14.jar. The correct version of these jars is normally not available in common maven repos (mostly because of license issue). Trick is to get these jars from Oracle installation you are trying to connect and add to local maven repo you are using.
There you go....
hii
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHi there. Do you perhaps have any sample code of trying to read an AQ into Camel but without spring? I'm very new to camel and try to avoid spring as much as possible :)
ReplyDelete