Announcement Announcement Module
Collapse
No announcement yet.
Spring Integration - outbound-channel-adapter query value from payload Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Integration - outbound-channel-adapter query value from payload

    Hi!

    Is it possible to assign -whole- outbound-channel-adapter query value from payload object?

    Code:
    	<int-jdbc:outbound-channel-adapter query=":query" data-source="resultDS" channel="databaseUpdateChannel"
    		sql-parameter-source-factory="OutboundChannelAdapterParameterFactory" />
    
    	<bean id="OutboundChannelAdapterParameterFactory" class="org.springframework.integration.jdbc.ExpressionEvaluatingSqlParameterSourceFactory">
    		<property name="parameterExpressions">
    			<map>
    				<entry key="query" value="payload.getResponseQuery()" />
    			</map>
    		</property>
    	</bean>
    payload.getResponseQuery() returns String "update Customer set name='unknown'" (for every row, just for simplicity)

    My biggest problem is I get various number of columns to be saved from a one of the previous services so query string can't be constant.

    BTW, how to get errors log from the outbound-channel-adapter?

    Thanks!
    Last edited by tom_ex; Jul 17th, 2012, 09:22 AM.

  • #2
    Hello

    I propose do not to use here <jdbc:outbound-channel-adapter>.
    Just write your own service, inject into it JdbcTemplate and apply Message as parameter.
    In other words: just use JdbcTemplate directly.
    Spring Integration adapters are designed to simplify and minimize end-developer work via some DSL.
    In your case after all JdbcTemplate hard work for your 'query' attribute value you're ending up on the
    Code:
    String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
    with this value: sqlToUse == "?". So it isn't correct SQL-query at all.

    Cheers,
    Artem Bilan

    Comment

    Working...
    X