Spring与Oracle AQ集成

时间:2016-01-27 08:30:37

标签: spring-integration oracle-aq

我正在尝试学习Spring Integration,为此我想创建一个这样的应用程序:

从Oracle发送消息(在Oracle Queue上),此消息将从Java应用程序(使用Spring Integration构建)中截取,应用程序将根据收到的消息发送电子邮件。该消息将包含To: - Cc:和要发送的文本。

为了进行这种沟通,我决定使用JMS(我认为在Oracle中这是用Oracle AQ制作的)。

在数据库中,我已经创建了Queue,现在我正在尝试创建一个简单的applicationContext.xml来启动此握手。

在网上看,我发现很少有关于此的文章(Spring Integration + Oracle AQ),并且我收到了一些错误。主要错误是:java.lang.ClassNotFoundException: oracle.jms.AQjmsFactory

现在这是我的applicationContext.xml

<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:orcl="http://www.springframework.org/schema/data/orcl" 
    xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
            http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
            http://www.springframework.org/schema/data/orcl  http://www.springframework.org/schema/data/orcl/spring-data-orcl-1.0.xsd">

    <int:channel id="inbound" />
    <int:channel id="outbound" />

    <bean id="simpleMessageListener" class="it.dirimo.SimpleMessageListener" />

    <int-jms:inbound-channel-adapter
        channel="inbound"
        connection-factory="connectionFactory"
        destination-name="Q1">  
        <int:poller fixed-delay="1000" />
    </int-jms:inbound-channel-adapter>

    <int:service-activator input-channel="inbound" output-channel="outbound" ref="simpleMessageListener" method="onMessage" />

    <int-jms:outbound-channel-adapter id="jmsOut" 
        channel="outbound" 
        connection-factory="connectionFactory"
        destination-name="sampleQueue" />

    <int:poller id="poller" default="true" fixed-delay="10000" />

    <orcl:aq-jms-connection-factory id="connectionFactory"
        data-source="dataSource"
        use-local-data-source-transaction="true"/>

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" lazy-init="false">
        <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
        <property name="url" value="jdbc:oracle:thin:@localhost:1521:ORCL" />
        <property name="username" value="user" />
        <property name="password" value="password" />
    </bean>
</beans>

也许我正在使用&#34; old&#34;技术(例如,我第一次看到这个org.apache.commons.dbcp.BasicDataSource

不幸的是,我对Spring Integration这么新,我第一次看到Oracle Queue(我使用Oracle工作但从未使用任何类型的队列)。

关于如何进行的一些建议将是apreciated:)

编辑1 要解决有关AQjmsFactory的问题,需要包含aqapi.jar

1 个答案:

答案 0 :(得分:2)

  

java.lang.ClassNotFoundException:oracle.jms.AQjmsFactory

这只是意味着你缺少从类路径中包含该类的jar。

通常,Oracle要求您直接从他们手动下载罐子。