Pergunta

I need to call a stored procedure which gathers data during a specific window. For instance I send in a Timestamp representing now, and a window of 15 minutes and it will return all data within the last 15 minutes. Each time this procedure is called I need update the Timestamp representing now so that I avoid old data.

Is there anyway to achieve this?

My attempt with the "now" bean below is a failure as even though that bean is a prototype it's value is only ever retrieved once when the channel adapter is created.

The anonymised stored-proc-inbound-channel-adapter I currently have configured is below:

<int-jdbc:stored-proc-inbound-channel-adapter
    channel="storedProcOutboundChannel" stored-procedure-name="dataWindowRetrieval"
    data-source="dataSource" auto-startup="true" id=""
    ignore-column-meta-data="false" is-function="false"
    skip-undeclared-results="true" return-value-required="false">

    <int:poller fixed-rate="60" time-unit="SECONDS"></int:poller>
    <int-jdbc:parameter name="CurrentDateTime" type="java.sql.Timestamp" value="#{now}" />
    <int-jdbc:parameter name="MinuteOffset" type="java.lang.Integer" value="3" />
    <int-jdbc:parameter name="SomeOtherParameter" type="java.lang.Integer" value="4" />
    <int-jdbc:parameter name="YetAnotherParameter" type="java.lang.Integer" value="15" />
    <int-jdbc:returning-resultset name="theResults" row-mapper="org.springframework.jdbc.core.ColumnMapRowMapper" />
</int-jdbc:stored-proc-inbound-channel-adapter>

<bean id="now" scope="prototype" class="java.sql.Timestamp">
    <constructor-arg value="#{ T(java.lang.System).currentTimeMillis()}" />
</bean>
Foi útil?

Solução

Instead of value use expression="@now".

The value is only evaluated at initialization time.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top