jpa 入站通道适配器不支持参数源

jpa inbound-channel-adapter doesn't support parameter source

我正在尝试使用参数源为入站通道适配器中的查询提供参数,但它似乎不起作用。我查看了解析器代码,但我认为它没有处理参数源。

<int-jpa:inbound-channel-adapter delete-after-poll="true"
    delete-in-batch="true" auto-startup="true" flush-after-delete="true"
    max-results="2000"
    entity-manager-factory="entityManagerFactory"
    entity-class="AuditMessage"
    channel="processMessage"
    jpa-query="select a from AuditMessage a where a.updateTs &lt; :purgeDate"
    parameter-source="parameterSource">
    <int:poller cron="*/5 * * * * *" >
        <int:transactional transaction-manager="transactionManager"/>
    </int:poller>
</int-jpa:inbound-channel-adapter>

<bean id="parameterSource" factory-bean="spelSource"
            factory-method="createParameterSourceNoCache">
    <constructor-arg value="" />
</bean>

<bean id="spelSource"
    class="org.springframework.integration.jdbc.ExpressionEvaluatingSqlParameterSourceFactory">
    <property name="parameterExpressions">
        <map>
            <entry key="purgeDate"
                value="new java.sql.Timestamp(T(System).currentTimeMillis()-(T(java.util.concurrent.TimeUnit).MILLISECONDS.convert(${eam.integration.arcgis.purge.daysToKeep}, T(java.util.concurrent.TimeUnit).DAYS)))" />
        </map>
    </property>
</bean>

我得到以下异常:

ERROR [task-scheduler-9] [java.lang.IllegalArgumentException: Query has parameters but no parameter source provided
at org.springframework.integration.jpa.core.DefaultJpaOperations.setParametersIfRequired(DefaultJpaOperations.java:330)
at org.springframework.integration.jpa.core.DefaultJpaOperations.getQuery(DefaultJpaOperations.java:114)
at org.springframework.integration.jpa.core.DefaultJpaOperations.getResultListForQuery(DefaultJpaOperations.java:186)
at org.springframework.integration.jpa.core.JpaExecutor.doPoll(JpaExecutor.java:396)...

我正在使用 spring 版本 4.0.3。难道我做错了什么?或者有其他方式提供查询参数吗?

我认为您刚刚发现了一个错误!

JpaInboundChannelAdapterParser 只是不解析 parameter-source 属性。欢迎提出 JIRA 错误。

作为一种解决方法,您必须将 JpaPollingChannelAdapter 配置为注入 JpaExecutor 的原始 <bean>,并将其用作来自通用 <int:inbound-channel-adapter>ref

JIRA ticket 适合那些想要跟踪的人。