int-jdbc:inbound-channel-adapter 更新查询的系统变量

System variable to the update query of int-jdbc:inbound-channel-adapter

我正在使用 int-jdbc:inbound-channel-adapter。 我的更新面临问题 statement.I 需要传递单个值,因为我在 RowMapper 中对该值进行了硬编码,这就是为什么我收到 5 个值而不是 1 个值的原因。(max-rows-per-poll=5)

我的要求:- 我需要将一个系统变量传递给 node_id 列和 5 个 ID select 从 select 查询到条件

<int-jdbc:inbound-channel-adapter id="itemsInboundJdbcChannelAdapter"
        auto-startup="true" data-source="dataSource" channel="ItemsInboundJdbcChannel"
        query="SELECT QXXXX_ID,BXXXX_ID,TXXXX_ID,RXXXX_ID,EXXXXID,NODE_ID FROM XXXX_QXXXX WHERE XXXX_STATUS = :identier ORDER BY QXXXX_ID asc FOR UPDATE SKIP LOCKED"
        update="UPDATE XXXX_QXXXX SET XXXX_STATUS ='IT_PROCESSED',NODE_ID=(:NODE_ID),UPDATE_BY='BISWO',UPDATED_ON=SYSDATE WHERE QXXXX_ID IN (:QXXXX_ID)"
        row-mapper="xxDataRowMapper" max-rows-per-poll="${item.transfer.jdbc.max.rows}"
        select-sql-parameter-source="myItemsSelectSqlParameterSource"
        update-sql-parameter-source-factory="myUpdateParameterSource">
        <int:poller id="jdbcPoller" fixed-delay="${item.transfer.poller.jdbc.fixed.delay}" task-executor="notificationExecutor"  error-channel="chainToFailedOut">
            <int:transactional transaction-manager="transactionManager" />
        </int:poller>
</int-jdbc:inbound-channel-adapter>

<int:service-activator input-channel="ItemsInboundJdbcChannel"
        ref="getMyService" >
        <int:poller fixed-delay="${item.transfer.poller.jdbc.fixed.delay}" />
    </int:service-activator>

<bean id="myUpdateParameterSource"
        class="org.springframework.integration.jdbc.ExpressionEvaluatingSqlParameterSourceFactory">
        <property name="parameterExpressions">
            <map>
                <entry key="NODE_ID" value=" #this['nodeId']"/>
                <entry key="QXXXX_ID" value="#this['qxxxxId']" />
            </map>
        </property>
</bean>

xxxDataRowMapper.java

@Override
public XXXDataModel mapRow(ResultSet rs, int rowNum) throws SQLException {
    XXDataModel object=null;
    if(rs!=null){
     long queueId=rs.getLong("QXXXX_ID");
     long batchId=rs.getLong("BXXXX_ID");
     long tradeRunId=rs.getLong("TXXXX_ID");
     long riskRunId=rs.getLong("RXXXX_RUN_ID");
    long eventId=rs.getLong("EXXXXID");
      object=new XXDataModel(queueId,batchId,tradeRunId,riskRunId,eventId,this.nodeId);
    }
    return object;
}

我认为您可以采用相同的 properties placeholder 方式并执行如下操作:

update="UPDATE XXXX_QXXXX SET XXXX_STATUS ='IT_PROCESSED',NODE_ID='${node_id.from-system.properties}', UPDATE_BY='BISWO',UPDATED_ON=SYSDATE WHERE QXXXX_ID IN (:QXXXX_ID)"

Spring 将理解您的 PP 模式,根据 Environment 解析它,最终值将出现在要使用的目标 SQL 语句中。