我正在尝试学习 Spring Integration,为此我想创建一个这样的应用程序:
从 Oracle 我发送消息(在 Oracle Queue 上),此消息将从 Java 应用程序(使用 Spring Integration 构建)中截获,应用程序将根据收到的消息发送一封电子邮件。该消息将包含收件人: - 抄送:和要发送的文本。
为了进行这种交流,我决定使用 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 队列(我使用 Oracle 工作,但从未使用过任何类型的队列)。
关于如何进行的一些建议将不胜感激:)
编辑 1 要解决有关 AQjmsFactory 的问题,需要包含 aqapi.jar