SQL删除查询不适用于Apache骆驼

时间:2020-02-26 12:58:17

标签: sql apache-camel

SQL Delete查询无法在骆驼中工作,因为它卡在SQL查询中,没有任何反应。试图直接在DB中执行相同的查询,它按预期工作正常。 下面是代码的简要介绍。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    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.xsd          http://camel.apache.org/schema/spring         http://camel.apache.org/schema/spring/camel-spring.xsd">
    <bean class="org.apache.commons.dbcp2.BasicDataSource"
        destroy-method="close" id="OracleConnection">
        <property name="driverClassName"
            value="${Oracle.DB.DriverClassName}" />
        <property name="url" value="${Oracle.DB.Url}" />
        <property name="username" value="${Oracle.DB.Username}" />
        <property name="password" value="${Oracle.DB.Password}" />
        <property name="initialSize" value="${Oracle.DB.InitialSize}" />
        <property name="maxTotal" value="${Oracle.DB.MaxTotal}" />
        <property name="minIdle" value="${Oracle.DB.MinIdle}" />
        <property name="maxIdle" value="${Oracle.DB.MaxIdle}" />
        <property name="testOnBorrow" value="true" />
        <property name="testOnReturn" value="true" />
        <property name="removeAbandonedOnMaintenance" value="true" />
        <property name="defaultAutoCommit" value="true" />
        <property name="maxWaitMillis"
            value="${Oracle.DB.MaxWaitMillis}" />
    </bean>
    <!-- configure the Camel SQL component to use the JDBC data source -->
    <bean class="org.apache.camel.component.sql.SqlComponent" id="sql">
        <property name="dataSource" ref="OracleConnection" />
    </bean>
    <camelContext id="GenerateOTPContext"
        xmlns="http://camel.apache.org/schema/spring">
        <route id="GenerateOTPMainRoute" streamCache="true">
            <from id="_from1"
                uri="restlet:http://localhost:9092/ESB/dbserviceapi/generateOTP?restletMethod=POST" />
            <setHeader headerName="deleteQuery" id="_setHeader2">
                <simple>sql:DELETE FROM MOBILE_OTP_DETAILS WHERE created_dt &lt; SYSDATE - INTERVAL '20' MINUTE</simple>
            </setHeader>
            <log id="_log2" message="Delete query ${header.deleteQuery}" />
            <recipientList delimiter="~" id="_recipientList2"
                ignoreInvalidEndpoints="true">
                <simple>${header.deleteQuery}</simple>
            </recipientList>
            <onException id="_onException1" useOriginalMessage="true">
                <exception>java.sql.SQLException</exception>
                <exception>java.lang.Exception</exception>
                <handled>
                    <constant>true</constant>
                </handled>
                <log id="_log3"
                    message="ESBUUID : ${exchangeId} Exception occurred in GenerateOTPAdapter : ${exception.stacktrace}" />
            </onException>
        </route>
    </camelContext>
</beans>

我正在使用dbcp2,pool2和camel-sql组件连接到数据库。

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

已经发现了问题,我已经创建了自己的表,但是错过了删除权限的授予,因此它没有从骆驼组件中删除数据库中的数据,所以我授予了表的权限,并且可以正常工作。