Announcement Announcement Module
Collapse
No announcement yet.
What data type does the channel send to a transformer Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • What data type does the channel send to a transformer

    What data-type does the channel send to a transformer?
    eg. if i am using this configuration

    <int-jdbc:inbound-channel-adapter
    data-source="datasource1" query="select * from course2" channel="input">
    <intoller fixed-rate="10" >
    </intoller>
    </int-jdbc:inbound-channel-adapter>

    so what does it send to the transformer?

    <bean id="courseTrasformer" class="org.mkcl.integration.service.CourseTrasform er"></bean>
    <int:transformer input-channel="input" output-channel="output"
    ref="courseTrasformer" method="transform" id="coursetransformer">
    </int:transformer>


    so what shud be the Datatype of the parameters in the method transform?
    Is it specific to the adapter we are using?

    Please help.

  • #2
    Hello.

    Is it specific to the adapter we are using?
    Of course it can be but isn't obligatorily: just to make the parameter as Object payload and take a look in the debug what you receive after JDBC-adapter.
    But it more simple: JDBC-adapters use on the background Spring JDBC, so in most cases it is JdbcTemplate which requires some implementation of RowMapper for queries.
    <jdbc:inbound-channel-adapter> are using ColumnMapRowMapper by default. In this case your result will be a List with Map elements, where each Map is a column/value presentation for your SELECT.

    Is it clear?

    Take care,
    Artem

    Comment


    • #3
      Thanks @Cleric

      One more query...
      I have to simply copy data from one schema to another
      the tables and schema are all ready..

      i m using the following code..
      <bean id="datasource2"
      ...
      </bean>

      <bean id="datasource1"
      ...
      </bean>

      <int:channel id="jdbcoutput">
      <int:queue capacity="100"/>
      </int:channel>

      <int-jdbc:inbound-channel-adapter data-source="datasource1" query="select * from course1" channel="jdbcoutput" >
      <intoller fixed-rate="1000"></intoller>
      </int-jdbc:inbound-channel-adapter>

      <int:service-activator ref="serviceactivator" input-channel="jdbcoutput">
      </int:service-activator>

      <int-jdbc:outbound-channel-adapter channel="jdbcoutput" query="WHAT SHUD I WRITE HERE?">
      </int-jdbc:outbound-channel-adapter>

      <bean id="serviceactivator" class="dmd.ddd.ddd.service.TempServiceActivator"></bean>

      =======================
      TempServiceActivator.java
      public List<course> getdata(List<Course> list){

      return list;
      }


      Since return type is a list..what shud i write in the jdbc:outbound-channel-adapter to write the database
      Is there no other option than writing the insert query?

      What is the best way to do this other than this noobe method.

      Comment


      • #4
        Hello!

        I'm not sure what fo you mean since your config looks wrong. But regarding <jdbc:outbound-channel-adapter> and your List.
        There is some trick: place before <jdbc:outbound-channel-adapter> <splitter>. So, it will look like this:
        HTML Code:
        <int:service-activator ref="serviceactivator" input-channel="serviceInput" output-channel="jdbcoutput"/>
        <chain input-channel="jdbcoutput">
          <splitter/>
          <int-jdbc:outbound-channel-adapter query="insert into ..."/>
        </chain>
        Is it appropriate?

        Comment


        • #5
          Thank you again.
          I am learning by doing.. so i m making so many mistakes.
          ok. we are inserting the data by using chain... i didn't think of it.. thanks
          but splitter...that i couldn't understand. please can u elaborate more... because splitter is used to split one complete message into different messages...so will the query take these separate methods to insert?

          And one more problem...
          since i m copying the data, the table will have primary keys.. so after inserting the data once, won't i get duplicate entry error because it will again try to insert them.
          and what if i have to update at some places and insert at some places?

          I am really learning a lot from u. So please help. Thanks a lot.

          Comment


          • #6
            Splitter
            will have primary keys
            It's up to you. You should understand what is the primary key in your case
            have to update at some places and insert at some places?
            You can achieve via JPA EntityManager.merge or via Stored Procedure:
            http://static.springsource.org/sprin...hannel-adapter
            http://static.springsource.org/sprin...hannel-adapter

            HTH

            Comment

            Working...
            X