Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Stardust/Knowledge Base/Integration/Camel/AMQ-OracleAQ-Bridge

Introduction

Stardust allows specifying JMS applications where one can send a request message and receive a response message. Within Stardust, messages are sent and acknowledgement is received from the configured queues (request-response) However there may be situations where we need to connect or send messages from Active MQ to another Messaging protocol or service. Sending messages from Active MQ to Oracle AQ is one such example.

Configuration

Active MQ 5.3

Camel JMS Component

The JMS component allows messages to be sent to (or consumed from) a JMS Queue or Topic. The implementation of the JMS Component uses Spring JMS support for declarative transactions using JmsTemplate for sending and MessageListenerContainer for consuming messages.

Oracle AQ (10g/11g)

Advanced Queuing leverages the functions of the Oracle database so that messages can be stored persistently, propagated between queues on different machines and databases, and transmitted using Oracle Net Services, HTTP(S), and SMTP.

Implementation Example

When triggered, a message is sent to the Active MQ Queue configured in the carnot-spring*.xml file and using one of the Transaction Managers. Then the messages are delegated to MQ topic and eventually to the Oracle Topic Configured in camel.xml. Messages are sent via this channel:
Active MQ Queue -> MQ Topic --> MQ Topic --> Oracle Topic


The following configurations are needed to activemq.xml to send messages over the ActiveMQ-Oracle AQ Bridge:

(This file can be found under <<Active MQ installed folder>>\apache-activemq-5.3.0\conf)

  • Specify the Oracle Topic Destination
<destinations>
<topic physicalName="OracleAQTopic"/>
</destinations>
  • Specify the Active MQ Queue Name and to forward topic name
<destinationInterceptors>
<virtualDestinationInterceptor>
<virtualDestinations>
<compositeQueue name="CarnotTestQueue" forwardOnly="false">
	<forwardTo>
	<topic physicalName="OracleAQTopic"/>
	</forwardTo>
</compositeQueue>
</virtualDestinations>
</virtualDestinationInterceptor>				
</destinationInterceptors>
  • Client Transport Connectors
<transportConnectors>
            <transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
</transportConnectors>
  • Oracle AQ Connection Factory Bean with Credentials
<bean id="requiredBeanForOracleAq" class="org.apache.activemq.ActiveMQConnectionFactory" /> 
			        <!--topic connection-->
<bean id="connectionFactoryOracleAQTopic" class="oracle.jms.AQjmsFactory" factory-method="getQueueConnectionFactory"> 
<constructor-arg index="0"> 
<value>jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS=(protocol=tcp)(host=<hostname>)(port=1521)
(Connect_Data= (SERVICE_NAME = <servicename>))))
</value> 
</constructor-arg>
 <constructor-arg index="1" type="java.util.Properties"> <value></value> </constructor-arg>
 </bean> 
<bean id="oracleTopicCredentials" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter"> 
<property name="targetConnectionFactory"> <ref bean="connectionFactoryOracleAQTopic"/> </property> 
<property name="username"> <value><username></value> </property> 
 <property name="password"> <value><password></value> </property> 
</bean> 
<bean id="oracleTopic" class="org.apache.camel.component.jms.JmsComponent"> 
<property name="connectionFactory" ref="oracleTopicCredentials"/>
</bean>
  • Import camel.xml in the activemq.xml
<import resource="camel.xml"/>

(Place this file under <<Active MQ installed folder>>\apache-activemq-5.3.0\conf) and add the following section to it

<camelContext> 
    <!-- Dependencies: ojdbc.jar and aqjms.jar must be in the activemq lib directory -->		    
    <route> 
     <from uri="activemq:topic:OracleAQTopic" /> 
     <to uri="oracleTopic:topic:topicname" />
    </route>  
</camelContext>
  • Configure the camel Activemq component to use the current broker
<!-- configure the camel activemq component to use the current broker -->
    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" >
        <property name="connectionFactory">
          <bean class="org.apache.activemq.ActiveMQConnectionFactory">
            <property name="brokerURL" value="vm://localhost?create=false&waitForStart=10000" />
            <property name="userName" value="${activemq.username}"/>
            <property name="password" value="${activemq.password}"/>
          </bean>
        </property>
     </bean>

References

Active MQ admin portal

http://<<host>>:<<port>>/admin

Oracle AQ

http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96587/qintro.htm


Back to the top