【问题标题】:Spring Integration with Oracle AQ与 Oracle AQ 的 Spring 集成
【发布时间】:2016-05-04 02:22:26
【问题描述】:

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

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

为了进行这种交流,我决定使用 JMS(我认为在 Oracle 中这是使用 Oracle AQ 进行的)。

在数据库中我已经创建了队列,现在我正在尝试创建一个简单的 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>

也许我正在使用“旧”技术(例如我第一次看到这个org.apache.commons.dbcp.BasicDataSource

不幸的是,我对 Spring Integration 很陌生,而且我第一次看到 Oracle Queue(我在工作中使用 Oracle,但从未使用过任何类型的 Queue)。

一些关于如何进行的建议将不胜感激:)

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

【问题讨论】:

    标签: spring-integration oracle-aq


    【解决方案1】:

    java.lang.ClassNotFoundException: oracle.jms.AQjmsFactory

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

    Oracle 通常要求您直接从它们手动下载其 jar。

    【讨论】:

    • 是的,我今天早上已经解决了这个问题:) 我需要包含 aqapi jar。我已经更新了我的回复,我在其中展示了我如何实现 jms 入站->出站。如果您在调试模式下运行我的程序,它可以工作,但我不知道如何“永远”运行它。应用程序甚至应该启动,当消息来自(来自 Oracle)时,应用程序应该处理它并发送邮件(稍后我将实现邮件部分,现在我只了解如何使应用程序“始终运行”)
    • 我正在研究 Spring 集成中的所有示例,但并不简单 :) 我现在的主要问题是如何很好地构建应用程序......我正在第一次体验 Spring(正如你已经知道的那样: )) 和 JMS。
    猜你喜欢
    • 1970-01-01
    • 2012-07-02
    • 1970-01-01
    • 2011-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多