Saturday, 15 May 2010

spring - Can I define the target table for int-jdbc:outbound-channel-adapter based on the received message? -


I Spring Integration JDBC support for continuing the message in one of the many tables (> 20) on the basis of a certain condition (As stored in the "Table" message header):

  & lt; Integer: Channel ID = "cmTablesJdbcChannel" & gt; & Lt; / Integer: channel & gt; & Lt; Puarnank- JDBC: outbound channel adapter channel = "cmTablesJdbcChannel" id = "cmTableJdbcOutputAdaptor" Data Source = "data source" query = "TABLE_NAME values ​​(int_id, parent_int_id, name) (insert values: headers [int_id],: headers [ Parent_int_id],: header [name]) "& gt; & Lt; / Integer-JDBC: Outbound channel-optimizer & gt;  

I have tried to change the TABLE_NAME many houses but no one did not work:

  $ {headers [ 'table']} # {header [ 'table']} [headers [table]}  

I am trying to avoid the use of 20 different outbound channel adapter and use a single again, But the name of the dynamic table was used to establish. Do you know that this is possible?

There were similar questions, but the parameters used are:

No, it does not work anymore and can not be in the form of the TABLE_NAME parameter.

issue feel free to take such as query expression to Insert / Update SQL at runtime against the request message.

Meanwhile, you should use NamedParameterJdbcTemplate to be used some custom & lt; Outbound channel-optimizer & gt; Or like a complex expression:

  & lt; Service-catalytic input channel = "cmTablesJdbcChannel" output channel = "nullChannel" expression = "@ jdbcTemplate.update (+ headers.table + 'inserted') (int_id, parent_int_id, name) values ​​(: int_id, parent_int_id ,: name ) ', Header) "/>  

Note, do not create SQL Expressions directly with parameter values. parametrized with version: : The best way for any RDBMS will be to compile it on server side (indexed, query scheme etc.) and reuse all other upcoming hangouts Will be done.


No comments:

Post a Comment